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

shaoxia-util

v1.1.2

Published

少侠的常用工具,欢迎补充添加

Readme

shaoxia-util

少侠的常用工具。

##安装

$ npm install shaoxia-util

##使用

import sUtil  from "shaoxia-util"
console.log(sUtil.is.Array([3,3])) //true

##功能列表

  • is.Array: 函数,传入js数据类型,返回是否为数组。

  • is.Boolean: 函数,传入js数据类型,返回是否为布尔值。

  • is.Date: 函数,传入js数据类型,返回是否为日期。

  • is.Number: 函数,传入js数据类型,返回是否数值。

  • is.Object: 函数,传入js数据类型,返回是否为纯对象。

  • is.Window: 函数,传入js数据类型,返回是否为window对象。

  • is.HTMLDocument: 函数,传入js数据类型,返回是否为HTMLDocument对象。

  • regMatch.IP: 函数,传入String,返回是否为IP.

  • regMatch.phone: 函数,传入String,返回是否为手机号.

  • regMatch.tel: 函数,传入String,返回是否为座机.

  • regMatch.idCard: 函数,传入String,返回是否为中国身份证号(只做格式校验,不验证其真实性).

  • regMatch.userName: 函数,传入三个参数(str,min,max)str是需要验证的字符串,min表示要求用户名最短长度,max表示要求用户名最大长度。即符合长度大于min,小于max,且只有字母数字和下划线的str,会返回true,否则返回false。

  • regMatch.password: 函数,传入三个参数(str,min,max)str是需要验证的字符串,min表示要求用户名最短长度,max表示要求用户名最大长度。即符合长度大于min,小于max,且只包含 0-9,a-z,~!@#$%^&*()+<> 中的字符的str,会返回true,否则返回false。

  • objToString: 函数,传入object,返回字符串,把object的key和value用等号连接,并把所有生成的字符串用"&"连接。

  • getQueryByName: 函数。getQueryByName(name,url)。name是必填参数,字符串型,指要获取的参数名,url是可选参数,表示url地址,默认是window.location.href;例如getQueryByName("name","http://www.8dou5che.com?name=shaoxia")将得到字符串"shaoxia";

  • dateFormat:函数。dateFormat(date,pattern),date是必填参数,这个参数可以传入 new Date()从而得到一个时间类型的,所以其值可以是date类型,可以是11位数字类型(时间戳),可以是特定的字符串(例如"Thu Apr 20 2017 14:37:08 GMT+0800 (中国标准时间)")。pattern,可选参数,字符类型。默认值"yyyy-MM-dd",表示要格式化成哪种格式。例如dateFormat(""Thu Apr 20 2017 14:37:08 GMT+0800 (中国标准时间)","yyyy年MM月dd日hh:mm:ss")可以转换成"2017年4月20日14:37:08"。

  • getValueByValue: 函数 getValueByValue(list,getKey,byValue,byKey)。list中为一组对象,这组对象具有相同的结构。要获取拥有某个键值对的对象某个key的值,就可以使用该方法。 list 为数组,getKey为希望获取的值,byValue和byKey是所要依据的键值对。例如getValueByValue([{a:1,b:"唐朝"},{a:2,b:"宋朝"}],"b",1,"a")可得到"唐朝"。

  • filterEmpty: 函数。传入 纯 key & value的object,输入object.将其value严格等于''、undefined、 null、NaN的 key/value剔除掉。一般用于向服务端发请求传参最后处理参数。