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

busyzz-lib

v1.0.6

Published

utils-lib

Downloads

2

Readme

Install

yarn add busyzz-lib
# or
npm install busyzz-lib --save

Modules 所有模块

(math,string,fns)

math

用于 number 计算,处理浮点数运算精度问题

import { math } from 'busyzz-lib';
let res = math.Multiply(20, 30);

Multiply 计算多个 number 的乘积

let res = math.Multiply(1.1, 2.2, 3.3);
res === 5, 5;

Divide 除法

let res = math.Divide(10, 2, 5);
res === 1;

Add 加法

let res = math.Divide(1, 2, 1.2);
res === 4.2;

Subtr 减法

let res = math.Divide(5.4, 2, 2);
res === 1.4;

RoundNum 四舍五入 保留 N 位小数

let res = math.RoundNum(12.887, 2);
res === 12.89;

RandomNum 获取大等于 min 小等于 max 的随机整数

math.RandomNum(min, max);
let res = math.RandomNum(2, 10);
res === 7;

string

用于常用的字符串处理

import { string } from 'busyzz-lib';

thousandNum 数字转换为金额

string.thousandNum(num:number,sign?:string = ',')
let res = string.thousandNum(212014)
res === '212,014'

getParams 获取 url 参数

string.getParams(search:string,name:string)
let res = string.getParams('?id=2','id')
res === '2'

limitFloat 限制输入的为 len 的小数

在表单 getValueFromEvent 里面使用 getValueFromEvent:e=>limitFloat(e,2)
e 为表单事件对象(下同)
string.limitFloat(target:number|string|e,len:number)
let res = string.limitFloat(1.234,2);
res === 1.23

formatNumber 限制输入为数字

在表单 getValueFromEvent 里面使用 getValueFromEvent:e=>formatNumber(e)
string.formatNumber(target:number|string|e)
let res = string.limitFloat('1.');
res === '1';

fns

常用的工具函数

filterObj 删除 数据为"" null undefined 的 key

fns.filterObj(obj:object);
let res = fns.filterObj({name:'',age:23})
res === {age:23}

getValueType 获取数据类型 (小写)

fns.getValueType(value:any);
let res = fns.getValueType('busyzz')
res === 'string'
let res = fns.getValueType(['busyzz'])
res === 'array'
let res = fns.getValueType({name:'busyzz',age:23})
res === 'object'

compose 合并多个函数

将 fn(gn(123)) -> Kn = compose(fn,gn); kn(123)
解决函数嵌套问题
react 里面使用案列
withRouter(HOC(Component))
fns.compose(withRouter,HOC)(Component)

deepClone 数据深拷贝

fns.deepClone(value:any)