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

comm-utils

v0.1.0

Published

antd components library

Downloads

3

Readme

组件使用说明

本地开发组件,建议使用npm run storybook启动

安装并引入组件

npm install comm-utils -S

import * as commUtils from "comm-utils";

数组-字符串转换方法

/*
将传入数据转换成数组并返回, separa:截取分隔符,默认“,”分割(可选)
*/
let resStr = commUtils.checkTypeBackArray(str, separa)

| 输入 | 输出 | | --------- | --------- | | commUtils.checkTypeBackArray('1,2,3,4')| ["1","2","3","4"] | commUtils.checkTypeBackArray("1;2;3;4", ";")| ["1","2","3","4"]

/*
将传入数据转换成字符串并返回, separa:截取分隔符,默认“,”拼接(可选)
*/
let resArr = commUtils.checkTypeBackString(arr, separa?)

| 输入 | 输出 | | --------- | --------- | | commUtils.checkTypeBackString([1,2,3,4])| "1,2,3,4" | commUtils.checkTypeBackString([1,2,3,4], ";")| "1;2;3;4"

时间-常用转化方法

禁止选择星期天

import { DatePicker } from "antd";

/*
禁止选择星期天--commUtils.disableDateWeek(e)
*/
<DatePicker
  disabledDate={e => commUtils.disableDateWeek(e)}
/>

禁止日期选择区间

/*
禁止日期选择区间
startDt: 开始日期(可选)
endDt: 结束日期(可选)
disBeforeToday: 选择今天之前的日期,默认false(可选)
dtFormat: 时间格式,默认“YYYY-MM-DD”(可选)
*/
开始日期使用--commUtils.disabledStartDt(e, startDt, endDt, disBeforeToday, dtFormat)
结束日期使用--commUtils.disabledEndDt(e, startDt, endDt, disBeforeToday, dtFormat)
<DatePicker
  disabledDate={e => commUtils.disabledStartDt(e, startDate, endDate)}
/>
<DatePicker
  disabledDate={e => commUtils.disabledEndDt(e, startDate, endDate)}
/>

传入日期,返回指定格式的日期

/*
  传入日期,返回指定格式的日期
  t: 不穿返回原数据, t=today返回当前日期(可选)
  dtFormat: 时间格式,默认"YYYY-MM-DD"(可选)
*/
commUtils.backFormatDate(t, dtFormat)

传入日期,返回moment格式的日期

/*
  传入日期,返回指定格式的日期
  dtFormat: 时间格式,默认"YYYY-MM-DD"(可选)
*/
commUtils.backFormatMoment(t, dtFormat)

对象-常用转化方法

判断对象多层结构数据是否存在、 不存在返回undefined

/*
  判断对象多层结构数据是否存在、 不存在返回undefined
  let KM_TEMPNOTICE_RECONSITU = commUtils.checkHasData(obj, ['OA_TACASEMGTAPPROVE', 'XML4CLOBINFO', 'CLOBINFO', 'KM_TEMPNOTICE_RECONSITU'])
*/

判断对象1中的值在对象2中是否相等 相等返回 true, 如果有一个值不相等返回false, objNew中新加的字段不作处理, 只对objPrep中的字段作处理

/*
  判断对象1中的值在对象2中是否相等 相等返回 true, 如果有一个值不相等返回false, objNew中新加的字段不作处理, 只对objPrep中的字段作处理
  objPrep原对象,objNew新对象
  arr指定数组里的key不比较,如['userID'] (可选)
  let objPrep = {
    a: 1,
    b: 2
  }
  let objNew = {
    a: 11,
    b: 2
  }
  commUtils.compareDataBlur(objPrep, objNew)
*/

| 输入 | 输出 | | --------- | --------- | | commUtils.compareDataBlur(objPrep, objNew)| false | commUtils.compareDataBlur(objPrep, objNew, ["a"])| true

输入正数限制,解析不出来返回undefined

/*
输入正数限制,解析不出来返回undefined
建议onChange方法使用
input输入数字限制e(value)
dotNum(小数位数) (可选)
commUtils.inputOnlyNumber(e, dotNum = 2)
*/

数字改千位分割

/*
数字改千位分割
commUtils.changeToThousand(num)
*/

千位字符串转正常数字

/*
千位字符串转正常数字
commUtils.stringToThousand(num)
*/

判断指是否为空 空位false 不为空为true

/*
判断指是否为空 空位false 不为空为true
commUtils.notNull(value)
*/

类组件专属方法change方法

/* 类组件专属方法
建议onChange方法使用
输入改变 e输入框值,obj={objKey: '对象的值', key: '键值'},
如:this.state.obj={a: '1'},则obj={objKey: 'obj', key: 'a'}
objKey 不存在直接设置到obj={ key: 'a'},this.state.a = '1'
type类型time、inputNumber,剩下的走默认 (可选)
cd回掉 (可选)
*/
commUtils.changeFun(e, _this, obj, type, cd)