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

cutils-ts

v0.0.306

Published

工具

Readme

[TOC]

Install

npm i cutils-ts or yarn add cutils-ts

Using

 import 'cutils-ts'
 const arr = [1,2,3,4]
 arr.sum()
 import {exportJsonToExcel} from "cutils-ts"
 exportJonsToExcel({...})

cutils-ts

工具类,包含Array Base Date Export Image Math Number Storage String Validate Websocket等


Array

  • 去重[unique]:
  • JSON去重[uniqueObj]:
  • 排序[_sort]:
  • JSON排序[sortObj]:
  • 平均值[balance]:
  • 并集[union]:
  • 交集[interp]:
  • 差集[except]:
  • 分组[group]:
  • 求和[sum]:
  • 交换位置[exchangePostion]:
  • 归档[archive]:

Base

  • 复制到剪切板[copy]:
  • 防抖[debounce]:就是指触发事件后在 n 秒内函数只能执行一次,如果在 n 秒内又触发了事件,则会重新计算函数执行时间。
  • 下载[download]:
  • Blob下载[downloadByBlob]:
  • 参数过滤[filterParams]:
  • 删除动画[removeLoadingAnimate]:
  • 滚动到顶部[scrollToHeader]:
  • 字符串ID[stringid]:
  • 节流[throttle]:就是指连续触发事件但是在 n 秒中只执行一次函数。
  • UUID[uuid]:

Date

  • 格式化[format]:
  • 时间是否在某个区间[isDuringDate]:
  • 某个时间距当前时间差[diff]:
  • 开始时间[startOf]:
  • 结束时间[endOf]:
  • 某月多少天[daysInMonth]:
  • 某年多少天[daysInYear]:
  • 日期是本年第几天[dayInYear]:
  • 日期是本周第几天[weekInYear]:
  • N年、N月、N周、N天、N小时、N分、N秒前时间[add]:大于0 未来,小于0 过去
  • N年、N月、N周、N天、N小时、N分、N秒后时间[subtract]:大于0 过去,小于0 未来

Export

  • Table导出数据[export_table_to_excel]
  • JSON导出数据[export_json_to_excel]

Image

  • 转Base64[toBase64]

Math

  • 加法[accAdd]
  • 除法[accDiv]
  • 乘法[accMul]
  • 平均值[average]
  • 根据条件求平均值[averageBy]
  • 帕斯卡三角[pascal]
  • 样本标准偏差/总体标准偏差[standardDeviation]
  • 减法[subtract]
  • 求start 到 end 的 power 幂累加[sumPower]
  • 函数执行的时间[takeTime]
  • 保留N位小数[toDecimal]
  • 将值转换为安全整数[toSafeInteger]

Number

  • 将阿拉伯数字翻译成中文的大写数字[numberToChinese]
  • 将数字转换为大写金额[changeToChinese]
  • 精度处理[_round]

Storage

  • 存Cookie[setCookie]
  • 取Cookie[getCookie]
  • 删Cookie[removeCookie]
  • 清Cookie[clearCookie]
  • 存Local[setLocalStorage]
  • 取Local[getLocalStorage]
  • 删Local[removeLocalStorage]
  • 清Local[clearLocalStorage]
  • 存Session[setSession]
  • 取Session[getSession]
  • 删Session[removeSession]
  • 清Session[clearSession]

String

  • 字符串字节[getBytesLength]

Validate

  • IE[isIE]
  • 密码强度[scorePassword]
  • 验证手机号并返回信息[validTel]
  • 手机号[isvalidPhoneNumber]
  • 数字[validateInteger]
  • 密码[isvalidPassword]
  • 合法URL[validateURL]
  • 小写字母[validateLowerCase]
  • 大写字母[validateUpperCase]
  • 大小写字母[validatAlphabets]
  • 手机机身码[isIMEI]
  • 视频链接[isVideoUrl]
  • 图片链接[isPicUrl]
  • 身份证号[isIdCard]
  • 金额[isMoney]
  • 车牌号含新能源[isVehicleNumber]
  • 移动设备[isMobile]
  • PC设备[isPc]
  • IOS设备[isIOS]
  • Android设备[isAndroid]
  • 微信设备[isWeiXin]

Websocket

  • websocket通信