npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@festardoctor/utils-util

v0.0.2

Published

基础工具组件.;

Downloads

1

Readme

Modules

@festardoctor/utils-util/Base64Utils

Base64操作模块

base64Decode(str) ⇒ String

Base64解码

Kind: Exported function

| Param | Type | | --- | --- | | str | String |

Example

Base64Utils.base64Decode("Uy5ILkkuRS5MLkQ=") === 'S.H.I.E.L.D'

@festardoctor/utils-util/LoadScript

loadScript(opts, callback) ⏏

动态加载外部JS脚本

Kind: Exported function

| Param | Type | | --- | --- | | opts | Object | | callback | function |

@festardoctor/utils-util/NumUtils

数字操作工具模块

num2str(num) ⇒ String

数字转成字符串

Kind: Exported function

| Param | Type | | --- | --- | | num | Number |

Example

NumUtil.num2str(654.560) === '654.56'

fillNumber(number, len, char) ⏏

字符串首部占位填充

Kind: Exported function

| Param | Type | Default | Description | | --- | --- | --- | --- | | number | Number | | 要填充的字符串 | | len | Number | 2 | 填充后的长度 | | char | String | 0 | 占位的字符,默认为'0' |

Example

NumUtil.fillNumber(34,3)==='034'
NumUtil.fillNumber(34,3,'@')==='@34'

@festardoctor/utils-util/ObjUtils

数据操作工具模块

ObjUtils.extend(destination) ⏏

对象合并,建议用Object.assign来替代

Kind: Exported function

| Param | Type | | --- | --- | | destination | Object |

ObjUtils.isEmptyObject(obj) ⇒ Boolean

判断给定的对象是否为空对象

Kind: Exported function

| Param | Type | Description | | --- | --- | --- | | obj | Object | 给定的对象 |

@festardoctor/utils-util/UrlUtils

URL操作工具模块

parseUrl(url) ⇒ Object

解析URL

Kind: Exported function Returns: Object - 解析后返回的对象, {"loc": loc,"params": params, "append": append}

| Param | Type | Description | | --- | --- | --- | | url | String | 需要解析的url |

Example

const url = 'https://m.meitun.com/pdetails.html?mtoapp=0&mtomeitun=302&sid=18405&pid=08010200640101&promotionId=18405&promotionType=1&topicType=1&url=//m.meitun.com/h5/group/group.html&index=1&referer_url=joingroup&referer_code=joingroupHot'
UrlUtils.parseUrl(url)
//return {'loc':'https://m.meitun.com/pdetails.html',params:{mtoapp:'0',mtomeitun:'302',sid:'18405',pid:'08010200640101',promotionId:'18405','promotionType':'1','topicType':'1',url:'//m.meitun.com/h5/group/group.html',index:'1',referer_url:'joingroup',referer_code:'joingroupHot'},append:{}}

getParams(url) ⇒ Object

获取URL的qs

Kind: Exported function Returns: Object - 返回qs

| Param | Type | | --- | --- | | url | String |

Example

const url = 'https://m.meitun.com/pdetails.html?mtoapp=0&mtomeitun=302&sid=18405&pid=08010200640101&promotionId=18405&promotionType=1&topicType=1&url=//m.meitun.com/h5/group/group.html&index=1&referer_url=joingroup&referer_code=joingroupHot'
UrlUtils.getParams(url)
//return {mtoapp:'0',mtomeitun:'302',sid:'18405',pid:'08010200640101',promotionId:'18405','promotionType':'1','topicType':'1',url:'//m.meitun.com/h5/group/group.html',index:'1',referer_url:'joingroup',referer_code:'joingroupHot'}

toCusString(obj) ⏏

组装URL

Kind: Exported function

| Param | Type | Description | | --- | --- | --- | | obj | Object | 类型{"loc": loc,"params": params, "append": append} |

Example

let obj = {loc: "https://m.meitun.com/pdetails.html",params: {a: 1, b: 2},append: "#aaa"}
let url = UrlUtils.toCusString(obj);
//return 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa'

appendParams(url, obj) ⏏

往给定url上追加参数

Kind: Exported function

| Param | Type | Description | | --- | --- | --- | | url | String | 给定的url | | obj | Object | 需要追加的参数键值对 |

Example

let url = 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa';
UrlUtils.appendParams(url, {a: 1})
//return 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa'

hasParam(url) ⏏

判断给定的URL是否带有query string

Kind: Exported function

| Param | Type | Description | | --- | --- | --- | | url | String | 给定的url |

getUrlParamByName(name) ⇒ *

查询location.href的queryString

Kind: Exported function Returns: * - 返回url 查询参数值 没有则返回null

| Param | Description | | --- | --- | | name | url 查询参数名 |

appendHref(href, key, value) ⏏

给指定的href增加参数

Kind: Exported function

| Param | Type | Description | | --- | --- | --- | | href | String | 指定的href | | key | String | 需要增加的参数名称 | | value | Number | String | Array | 需要增加的参数值 |

Example

let url = 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa';
UrlUtils.appendHref(url, a,1)
//return 'https://m.meitun.com/pdetails.html?a=1&b=2#aaa'