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

fnutools

v2.1.3

Published

javaScript的工具函数1

Downloads

3

Readme

fnutools

介绍

javascript工具类函数,内置各种常用工具函数,如树搜索、深拷贝、时间格式处理、数字格式处理等

安装

npm i fnutools

使用

  1. 全部引入 imort fnutools from 'fnutools'
  2. 按需引入 imort { treeSearch, checkType} from 'fnutools'

文档

treeSearch(treeOriginData, searchData, matchKey)

函数描述:树搜索 | params | 是否必填 |数据类型| 描述 | |----------------|------|-------------|------------| | treeOriginData | 必填 |Array| 树的源数据,可以理解为渲染页面树的备份数据 | | searchData | 必填 |String| 需要被匹配的文本,可以理解为搜索框中的用户输入 | | matchKey | 必填 |String| 指定树源数据中通过那一个key去匹配searchData |

checkType(data)

函数描述:判断数据类型 | params | 是否必填 |数据类型| 描述 | |--------|------|----|----| | data | 必填 |any| 数据 |

说明:支持以下9种数据类型检验 | 类型 | 描述 | |-----------|-----| | Number | 数值 | | String | 字符串 | | Object | 对象 | | Array | 数组 | | Boolean | 布尔值 | | Date | 时间 | | Function | 函数 | | Undefined | undefined | | Null | Null |

arrayDeduplyObject(array,key)

函数描述:Array<object/object>去重 | params | 是否必填 |数据类型| 描述 | |--------|------|---------------|--------| | array | 必填 |Array| 数组 | | key | 必填 |String| 指定根据那个key的值去重 |

arrayDeduply(array)

函数描述:Array<string/number>去重 | params | 是否必填 |数据类型| 描述 | |--------|------|----|----| | array | 必填 |Array| 数组 |

clone(data)

函数描述:引用数据类型深拷贝,目前仅支持引用数据类型Object、Array实现深拷贝 | params | 是否必填 |数据类型| 描述 | |--------|------|----|----| | data | 必填 |any| 数据 |

moment()

函数描述:时间格式处理函数,继承自moment.js

numberFormat(number, sliceLength, str, isInit)

函数描述:数字处理函数 | params | 是否必填 | 数据类型 | 描述 | |-------------|------ |----------|----------| | number | 必填 | string/number | 需要处理的数字 | | sliceLength | 必填 | number | 每段显示几个数字 | | str | 必填 | string | 每段的分隔符 | | isInit | 必填 | boolean/number| 是否显示小数,true的时返回的小数部分和传入的一致,false时取整,number设置保留几位小数 |

例子:

 console.warn(numberFormat(12345.6765, 3 , ',' , 2));  //12345.68
 console.warn(numberFormat(123456765, 4 , ' ' , false));  //1 2345 6765

renderCallback(selector, callback)

函数描述:指定的dom在页面渲染完成以后的回调函数

| params | 是否必填 | 数据类型 | 描述 | |----------|------|----------|--------| | selector | 是 | string | css选择器 | | callback | 是 | function | 回调函数 |

renderCallback('.box', (dom) => {
    console.warn('dom', dom)
})