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 🙏

© 2026 – Pkg Stats / Ryan Hefner

wd-tools-utils

v1.1.1

Published

一个工具库

Readme

wd-tools-utils

一个常用的工具库

validate

说明

校验类

方法

validate.IdCard(arg) validate.Mobile(arg)

用法

import { validate } from "wd-tools-utils";

validate.IdCard('110221222255555566') // 返回 true
validate.Mobile('15999931234') // 返回 true

formatDateTime(时间戳转时间)

说明

时间戳转时间

参数

filterTime(timestamp,format)

支持的格式

YY-MM-DD HH:MM:SS YY-MM-DD HH:MM YY-MM-DD YY-MM YY/MM/DD HH:MM:SS YY/MM/DD HH:MM YY/MM/DD YY/MM

用法

import { formatDateTime } from "wd-tools-utils";

formatDateTime(1589279121,'YY-MM-DD HH:MM:SS')

storage(本地存储)

说明

由于项目中常需用到本地storage存储,复杂的数组、对象等,每次都需要JSON.stringify()和JSON.parse()进行序列化、反序列化操作,再者,存入storage的数值,取出来就变成字符串了,因此,对storage简单封装,使取出的值类型和存入时保持一致,也可以存入整个object对象。

1、存储单个值

storage.set('name', 'esther');

2、获取单个值

storage.get('name');

3、删除单个值

storage.remove('name');

4、清空全部

storage.clear();

5、存储对象,key - value形式

storage.setList({
  a: '1',
  b: '2.1',
  c: ['a', 'b', 'c'],
  d: {
    'd-1': 'd-1',
    'd-2': 'd-2'
  },
  e: true,
  f: new Date(),
  g: function(){
    console.log(111);
  }
});

6、获取多个值,传入数组形式的key

storage.getList(['a', 'b', 'd', 'f']);

7、删除多个值,传入数组形式的key

storage.removeList(['a', 'b', 'd', 'f'])

8、sessionStorage, api同上

storage.session.set('name', 'esther');

用法

import { storage } from "wd-tools-utils";
storage.set('ceshi',
  {
  a: 123,
  b: [1, 2, 4],
  c: {
    asd: 666,
  },
});
console.log(storage.get('ceshi'));

*默认localStorage, 使用sessionStorage的话,请使用storage.session

calculate

说明

四则运算方法——解决日常运算的精度丢失问题

方法

/**
 * 加法函数解决精度丢失问题
 * @param { number } arg1
 * @param { number } arg2
 */

calculate.add(arg1, arg2)
/**
 * 减法函数解决精度丢失问题
 * @param { number } arg1
 * @param { number } arg2
 */

calculate.subtraction(arg1, arg2)
/**
 * 乘法函数解决精度丢失问题
 * @param { number } num1
 * @param { number } num2
 */

calculate.multiplication(arg1, arg2)
/**
 * 除法函数解决精度丢失问题
 * @param { number } arg1
 * @param { number } arg2
 */
calculate.division(arg1, arg2)

用法

import { calculate } from "wd-tools-utils";

calculate.add(0.1, 0.3) // 返回 true
validate.Mobile('133659988714') // 返回 true