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 🙏

© 2025 – Pkg Stats / Ryan Hefner

jrd-utils

v2.7.4

Published

```bash pnpm install jrd-utils 或 yarn add jrd-utils 或 npm install jrd-utils ``` ## 当前版本:2.7.1 | 版本号 | 日期 | 修订人 | 审核人 | 修订内容 | |---|---|---|---|---| | 2.7.1 | 2025-12-18 | 黄柳 | 袁勃 | 初始版本 |

Readme

jrd-utils 使用手册

下载

pnpm install jrd-utils 或 yarn add jrd-utils 或 npm install jrd-utils

当前版本:2.7.1

| 版本号 | 日期 | 修订人 | 审核人 | 修订内容 | |---|---|---|---|---| | 2.7.1 | 2025-12-18 | 黄柳 | 袁勃 | 初始版本 |

下面给出 utils 目录下所有公共函数的“一句话说明 + 调用示例”,复制即可运行。


1. base64 编码解码

| 函数 | 作用 | 示例 | |---|---|---| | base64.Base64encode(str) | 编码 | base64.Base64encode('hello')'aGVsbG8=' | | base64.Base64decode(str) | 解码 | base64.Base64decode('aGVsbG8=')'hello' |


2. desensitization 脱敏

| 函数 | 作用 | 示例 | |---|---|---| | desensitization.mask(str,start,end,mask) | 通用脱敏函数 | desensitization.mask('hello',2,3,'*')'he*lo' | | desensitization.maskPhone(phone) | 手机号脱敏(保留前3后4) | desensitization.maskPhone('13800138000')'138****8000' | | desensitization.maskIdCard(idCard) | 身份证脱敏(保留前3位和后4位) | desensitization.maskIdCard('44030419900101001X')'440****001X' | | desensitization.maskBankCard(bankCard) | 银行卡脱敏(保留前4后4) | desensitization.maskBankCard('6217001234567890123')'6217****7890123' | | desensitization.maskEmail(email) | 邮箱脱敏(保留前1后1) | desensitization.maskEmail('[email protected]')'a*@b.cc' |


3. encode 编码

| 函数 | 作用 | 示例 | |---|---|---| | encode.objectToQueryString(obj,encode=true) | 将对象转换为查询字符串 | encode.objectToQueryString({a:1,b:'2'})'a=1&b=2' | | encode.jrdDecryptByAES(string,token) | AES解密 | encode.jrdDecryptByAES('encData','token')'{"a":1,"b":"2"}' | | encode.jrdEncryptByAES(string,token) | AES加密 | encode.jrdEncryptByAES('{"a":1,"b":"2"}','token')'encData' | | encode.jrdEncryptBySM4(string,apikey) | SM4加密 | encode.jrdEncryptBySM4('{"a":1,"b":"2"}','apikey')'encData' | | encode.jrdDecryptBySM4(string,hospitalId) | SM4解密 | encode.jrdDecryptBySM4('encData','123')'{"a":1,"b":"2"}' | | encode.sortSignDatatoString(data) | 加密参数排序转字符串 | encode.sortSignDatatoString({b:'2',a:1})'a=1&b=2' | | encode.getJrdSign(path,method,data,hospitalId,token,token_key,baseUrl,queryHospitalKeyUrl,signUrl,apiNeedSignUrl) | 获取签名 | encode.getJrdSign('/api/encrypt','POST',{a: 1,b: '2',},'123','token','token_key','https://api.jrd.com','/api/queryHospitalKey','/api/sign','/api/encrypt',)'sign' |

4. idcard 身份证号

| 函数 | 作用 | 示例 | |---|---|---| | idcard.getGender(idCard) | 根据身份证号码判断性别 | idcard.getGender('44030419900101001X')'男' | | idcard.getAge(idCard) | 根据身份证号码计算年龄 | idcard.getAge('44030419900101001X')35 | | idcard.getBirthDate(idCard,birthDateSplit='-') | 根据身份证号码提取出生日期 | idcard.getBirthDate('44030419900101001X','-')'1990-01-01' |


5. jwt

| 函数 | 作用 | 示例 | |---|---|---| | jwt.decodeJwt(token) | 解码JWT | jwt.decodeJwt('token'){ header: { ... }, payload: { ... } } |


6. lib

| 函数 | 作用 | 示例 | |---|---|---|

| sm4.encrypt(str,apiKey) | SM4加密 | sm4.encrypt('hello','apikey')'encData' | | sm4.decrypt(str,apiKey) | SM4解密 | sm4.decrypt('encData','apikey')'hello' |


7. location 获取地址栏数据

| 函数 | 作用 | 示例 | |---|---|---| http://192.168.0.100:3000/#/login?a=1 | location.getParam(name) | 获取 URL 参数 | getParam('a')'1' |

8. resource 资源携带token访问

| 函数 | 作用 | 示例 | |---|---|---| | resource.getAuthResource(url,token) | 图片携带token访问 | getAuthResource('https://api.jrd.com/api/encrypt','token')'blob:http://192.168.0.100:3002/a99d170c-2088-4af4-9280-2e90f55dfe1e' |

9. validator 校验器

| 函数 | 作用 | 示例 | |---|---|---| | validator.phone(phone) | 校验手机号 | validator.phone('13800138000')true | | validator.idCardNumber(idCard) | 校验身份证号 | validator.idCardNumber('44030419900101001X')true | | validator.email(email) | 校验邮箱 | validator.email('[email protected]')true | | validator.commonPassword(password) | 校验常用密码(8-16位,包含数字、字母、特殊字符) | validator.commonPassword('123456')false |