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

utils-tools-djj

v0.0.3

Published

个人工具库

Readme

utils-tools-djj

这个库有些是根据自身项目遇到一些常用自己封装的工具函数,市面上也有许多工具函数库,功能都很齐全,我为啥还要自己搞一个工具库呢?

第一点:市面上的工具库确实丰富,但是我们做项目的不一定都用到那些工具函数,如果项目是多人合作开发的情况下,每个人都有自己喜欢的第三方工具库,没有统一标准,那样导致项目依赖会很杂,维护不好维护。

第二点:编写自己的工具库自己方便维护升级,别人的库你不能保证人家会维护,有些刚开始是开源的,但后期有不确定因素不开源了,这个库依赖找不见等等一些因素。

第三点:整理自己的工具,自己封装的工具库或者组件都整理起来,方便自己对自己开发的一个总结,后期开展新项目能快捷的找到自己写的,不用再去翻找自己旧项目从里面复制出来,会大大提升自身的开发效率

防抖/节流

| 方法 | 参数 | 描述 | | :------: | :-----------------------------: | :------: | | throttle | [Function,wait] wait默认值500ms | 函数节流 | | debounce | [Function,wait] wait默认值500ms | 函数防抖 |

处理时间的一些方法

| 方法 | 参数 | 描述 | 返回值 | | :--------: | :--------------------: | :----------------------------------------------------------: | :--------------------------------: | | timeFormat | [Date,string:默认是空] | 给定一个时间,返回相对应格式默认返回 "yyyy-mm-dd hh:MM:ss" 格式 | "2024-01-16 00:00:00" | | formatPast | [Date] | 根据时间对比距离当前时间,如果时间小于1000ms返回值是刚刚,如果超过1秒则会返回1秒前 | 刚刚/n秒前/分钟前/n小时前/n天前... |

处理数组的一些方法

| 方法 | 参数 | 描述 | 返回值 | | :------------: | :-----------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | | intervalValue | [arr,object,number] | 给定一个数组,如果传入第三个参数,会返回这个数组的区间值;第二个参数固定格式{text:"这里只能是数值类型",value:"需要返回的值"} | 例:intervalValue([20,30,60],{},15);返回值是[0,20]; intervalValue([{color:"red",code:20},{color:"green",code:60},{color:"blue",code:80}],{text:"code",value:"color"},15);返回值是red | | dataFlattening | [arr,string] | 扁平化数组,第二个参数默认是children,可根据字段名称传值 | 例:dataFlattening([{text:"aa",children:[{text:"bb",children:[{text:"cc"}]}]}]); 返回值是[{text:"aa",children:[...]},{text:"bb",children:[...]},{text:"cc",children:[]}] | | splitData | [arr,number] | 给定一个数组,对数组进行数据分组 | 例:splitData([20,30,40,50,60],2);返回值[[20,30],[40,50],[60]] |

其他的方法

| 方法 | 参数 | 描述 | 返回值 | | :--------------: | :------: | :--------------: | :----------------------------------------------------------: | | digitalToChinese | [number] | 将数字转换成中文 | 例:digitalToChinese(110500000.06);返回值:一亿一千零五十万点零六 | | toBigChine | [number] | 将数字转换成大写 | 例:toBigChine(110500000.06);返回值:壹亿壹仟零伍拾万点零陆 |