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

paul-utils-js

v1.1.16

Published

这是一个js工具代码库

Downloads

146

Readme

安装 npm i paul-utils-js

使用 import { arrayDeweighting } from 'paul-utils-js'

快速查找API名

  • 1、arrayDeweighting:数组去重
  • 2、fuzzySearch:模糊匹配
  • 3、ArrayObjectsAreDeduplicated:去除数组对象中重复值
  • 4、timestampToDate:时间戳转为年月日
  • 5、doDateParse:解析一个表示某个日期的字符串,返回时间戳 str='Wed Nov 01 2023 00:00:00 GMT+0800 (中国标准时间)'
  • 6、getCurrentDate:获取当前时间,可以按照要求返回不同格式的时间字符串
  • 7、getDataType:js数据类型判断
  • 8、objectPropertyEmptying:遍历对象、删除属性值为空的属性名
  • 9、getQueryString:根据传入参数名获取浏览器地址栏参数值
  • 10、regularExpression:返回一个正则表达式
  • 11、encodeDeencode:对中文URl进行编码解码
  • 12、debounce:函数防抖
  • 13、throttle:函数节流
  • 14、imgToBase64:图片转为Base64
  • 15、blobFormat:接收blob文件流,实现下载
  • 16、getStartAndEndTimestamps:获取近几个小时的开始和结束的时间戳
  • 17、findTargetObjFromArr:判断数组对象中是否包含某个对象,或者返回符合条件的元素的集合

1、arrayDeweighting:数组去重

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- arr|是|Array|-|目标数组 key|否|String|id|检测是否重复的目标字段 position|否|String|end|处理重复后保留前面的还是后面的【'start':保留第一位;'end':保留最后一位】

2、fuzzySearch:模糊匹配

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- arr|是|Array|-|目标数组 key|是|String|-|匹配关键字 value|是|String|-|文本框输入值

3、ArrayObjectsAreDeduplicated:去除数组对象中重复值

参数名|是否必填|类型|默认值|可选参数|描述 --|--|--|--|--|-- tempArr|是|Array|-|-|需要去重的数组 key|否|String|id|-|数组里面每条对象的主键

4、timestampToDate:时间戳转为年月日

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- timestamp|是|Number/String|-|需要转化的时间戳,单位毫秒 format|否|String|YYYY-MM-DD【可选:MM-DD】|输出的日期格式

5、doDateParse:解析一个表示某个日期的字符串,返回时间戳 str='Wed Nov 01 2023 00:00:00 GMT+0800 (中国标准时间)'

参数名|是否必填|类型|默认值|可选参数|描述 --|--|--|--|--|-- str|是|String|-|-|解析一个表示某个日期的字符串,返回时间戳

6、getCurrentDate:获取当前时间,可以按照要求返回不同格式的时间字符串

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- type|否|String|-|需要返回的日期格式

7、getDataType:js数据类型判断

参数名|是否必填|类型|默认值|可选参数|描述 --|--|--|--|--|-- data|是|Any|-|-|js数据类型判断

8、objectPropertyEmptying:遍历对象、删除属性值为空的属性名

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- obj|是|Object|-|-

9、getQueryString:根据传入参数名获取浏览器地址栏参数值

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- name|是|String|-|需要获取浏览器地址栏的参数名

10、regularExpression:返回正则表达式

参数名|是否必填|类型|默认值|可选参数|描述 --|--|--|--|--|-- type|是|String|-|'手机号'、'身份证'、'邮政编码'、'社会统一信用码'、'非零的正整数'、'汉字'、'数字'、'中文、英文、数字包括下划线'、'邮箱'、'域名'、'ip'、'字符集【不能有中文】、字母和数字'| 返回一个正则表达式

11、encodeDeencode:对中文URl进行编码解码

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- target|是|String|-|需要编码、解码的URL字符串 type|否|String|encoding|类型。encoding:编码 decoding:解码

12、debounce:函数防抖

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- func|是|Function|-|目标函数 delay|否|Number(毫秒)|1000|延时时间 参数1|否|Any|-|func函数需要用到的参数 参数2|否|Any|-|func函数需要用到的参数 .......

13、throttle:函数节流

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- func|是|Function|-|目标函数 delay|否|Number(毫秒)|1000|延时时间 参数1|否|Any|-|func函数需要用到的参数 参数2|否|Any|-|func函数需要用到的参数 .......

14、imgToBase64:图片转为base64码

参数名|是否必填|类型|默认值|描述 --|--|--|--|-- url|是|String|-|储存在服务的图片地址 callback|是|Function|-|转化成功后的回调函数

15、blobFormat:接收blob文件流,实现下载

参数名|是否必填|类型|默认值|可选参数|描述 --|--|--|--|--|-- myBlob|是|Blob|-|-|文件流 fileName|是|String|-|-|文件名 suffix|是|String|-|-|后缀名

16、getStartAndEndTimestamps:获取近几个小时的开始和结束的时间戳

参数名|是否必填|类型|默认值|可选参数|返回参数|描述 --|--|--|--|--|--|-- hours | 是 | Number | - | - | {start:戳, end:戳}| 近多少个小时,如果要获取近几天就传:n(天)* 24

17、findTargetObjFromArr:判断数组对象中是否包含某个对象,或者返回符合条件的元素的集合

参数名|是否必填|类型|默认值|可选参数|描述 --|--|--|--|--|-- arr | 是 | Array{Object} | - | - |目标数组 target | 是 | Object | - | - |判断条件。对象里目前只支持一个条件 type | 否 | Number | 1 | 1、2 |1:代表只判断是否有符合条件的元素,有返回true,没有返回false。 2:代表返回所有符合条件的元素的集合