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

platform-library-utils

v1.0.0

Published

platform library web common utils

Readme

前端工具类库使用方式

  1. 按需进行导入,以下列出的内容均支持按需导入。且都在全局命名空间下。
import { isNumber } from 'platform-library-utils'
isNumber(123) => true

数据类型检测

1. isEmpty     //检测是否是空 (null、undefined、'')
2. isNumber    //判断参数的类型是否是数值类型
3. isString    //检测是否是字符串
4. isJSON      //检测是否是JSON
5. isArray     //检测是否是数组
6. isObject   //检测是否是对象
7. regexpCheck   //自定义正则检测值
8. regexpPromiseMsg   //自定义正则检测值并回调自定义提示消息
9. isWrapObj           //检测一个类型是否是包装类型
9. isObjInProVail           //判断指定属性名是否存在于对象中
10. isMobile           //校验当前登录平台是否是移动端

数据类生成

1. randomstring     //随机生成32位(N位)随机数
2. getPrefixStr     //获取指定字符串前的内容
3. getSuffixStr     //从最右端获取指定字符串后的内容
3. spreadOutList     //递归展开多维数组为一维数组
3. duplicateRemovalList     //根据指定 key 对对象数组去重
4. trimWhiteSpace     //移除字符串中指定的字符
5. replaceAllStr     //替换字符串中所有指定的字符
6. transformArrToString     //将数组转为字符串
7. transformStringToArr     //将字符串转为数组
8. transformCamelToUnderline     //将字驼峰命名的字符串转为下划线分割的字符串
9. transformUnderlineToCamel     //将下划线分割命名的字符串转为驼峰的字符串
10. getUrlParam     //获取地址栏参数
11. treeDataToArray     //将树结构转换为集合
12. arrayToTreeData     //将集合转换为树结构
12. getAllParentArr     //根据节点id,获取其所有父节点
13. getCheckListByTree     //给定一个集合checkList   返回该集合在树形结构中对应的对象
13. getDataByTree     //判断指定数据是否存在于树结构中,返回匹配到的节点对象数组(只返回第一个匹配结果)
14. deepClone     //深拷贝
15. deleteObjectProperty     //移除对象的指定的属性
16. deleteEmptyProperty     //删除空属性
17. formatAmount     //金额千位符转换
18. deepCopy  //深拷贝
19. deepClone  //深拷贝
20. useForm  //hooks 深拷贝和复制

数字相关

1. formateNumber     //格式化数字保留指定的精度
1. formatNumberToPrecision     //将base64转换为图片
1. formatNumberToPrecision     //保留两位小数,只截取不四舍五入
1. performCalculation     //精确计算两个数字的加减乘除,避免浮点数精度丢失
1. calculateAndFormatToTwoDecimals     //根据传递数字进行运算,并返回两位小数的数据(字符串类型)

图片类

1. imageLongWideProportion     //获取图片的宽高比例
1. base64ToImg     //将base64转换为图片
1. compressImg     //压缩图片
1. getBase64ToImgUrl     //将base64字符串(非dataURL,仅base64编码)转为图片URL
1. getImageWH     //获取图片文件的宽高信息

文件相关

1. downFile     //下载文件 或者使用file-saver 插件
2. blobToFile   //将blob类型转换为file类型
3. base64ToFile //将base64转换为file类型
4. getBase64    //将file类型转换为base64

时间相关

1. formatTime     //根据传递时间戳和类型 返回指定的时间格式
2. dayTime   //获取指定日期的开始和结束的时间戳
3. getQuarterStartDate //获得本季度的开始和结束的时间戳
4. getQuarterStartMonth    //获得本季度的开端月份
5. getMonthDays    //获得某月的天数
6. getDateOldAndNewTime    //获取N天后或者N天前的时间戳
7. surplusDay    //获取本月剩余到少天
8. monthTime    //根据指定 年和月获取 指定月的开始时间和结束时间戳
9. getNowDateAndNowWeek    //获取时间戳周的开始时间和结束时间
10. getMonthWeek    //获取当月的第几周
11. yearTime    //获取指定年的开始时间戳和结束时间戳
11. getMonth    //获取指定时间的年月字符串
11. secondsToHms    //时分秒转化
11. getDaysBetween    //获取两个日期之间的所有日期字符串(格式化

发布组件

npm publish --registry  http://******

撤销发布

npm unpublish --registry http://****** --force  platform-library-utils

安装组件

npm i --registry  http://****** platform-library-utils -D