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

trs-web-utils

v1.1.2

Published

拓尔思前端通用utils

Readme

trs-web-utils

前端通用utils方法

包含utils方法

formatterTime(time):功能:将时间戳转换为相较于当前时间的通用描述,如几分钟前、几天前、几个月前。参数time:需要转换表述的时间戳 toCode(str, key):功能:字符串加密。参数str:需要进行加密的字符串,参数key:用于加密的密匙 fromCode(str, key):功能:字符串解密。参数str:需要进行解密的字符串,参数key:用于解密的密匙 getUrlKey(key, url):功能:获取url中指定参数key的值。参数key:需获取参数值的目标key,参数url:用于获取参数值的url numToChinese(num):功能:将数字转换为中文读法。参数num:需要转换的数字 wanToYi(value):功能:将单位为万的数字转换为单位为亿的单位,不满五位数单位依旧为万。参数value:需转换单位的值(wanToYi(11) -> 11万;wanToYi(11111) -> 1.11亿) numberToYi(value, returnType):功能:数字转换为万或亿为单位的数据。参数value:需转换单位的值(numberToYi(11) -> 11;numberToYi(11111) -> 1.11万;numberToYi(111111111) -> 1.11亿),参数returnType:转换后返回数据的类型,不传默认返回字符串,可选值'object',传入后返回一个Object对象,参考值{value: 1.11, unit: "亿"} formatDuring(time):功能:时间格式转换,将时间戳转换为x天x小时x分钟x秒。参数time:需要转换的时间戳 timestampToNormal(date, format = '-'):功能:将时间戳转化为yyyy-MM-dd。参数date:需要转换的时间戳,参数format:分隔年月日的字符,默认为'-' timestampToDateTime(date, format = '-'):功能:将时间戳转化为yyyy-MM-dd hh:mm:ss。参数date:需要转换的时间戳,参数format:分隔年月日的字符,默认为'-' shortNum(num):功能:精简数字。参数num:需要精简的数字,shortNum(100) -> 100,shortNum(1000) -> 1.00k,shortNum(10000) -> 1.00w expordFile(res, fileName):功能:文件保存。参数res:后端接口返回数据,参数fileName:下载时展示的下载文件名 getUUID():功能:生成不重复的uuid formatterProvince(areaValue, end):功能:省市区格式处理。参数areaValue:省市区名,参数end:需要处理的省市区最后一个字的值,如:市(用于判断直辖市及地级市) computedTextWidth2(text, fontSize = 14):功能:获取文字长度。参数text:需计算长度的文本,参数fontSize:文本字号 copyText(text, success = null, fail = null):功能:复制文本。参数text 复制的内容,success 成功回调,fail 出错回调 downloadFile(data, fileList, title):功能:打开文件的目录进行选择目录并保存文件。data:文件数据,fileList:文件列表,title:文件下载名称