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

@mohun/tools

v1.0.3

Published

个人工具库

Readme

介绍

  • https://lml110.github.io/Tools/#/
  • http://lmlmyfok.gitee.io/lmltools/#/
  • https://docs.winbaoxian.cn/tools/#/

辅助函数库

常用

debounce - 防抖函数

definePros - 对象绑定- 使附加的方法为只读

getFileExtName - 获取后缀名并转换小写

getFileName - 获取文件名称

getFormData - 获取formData

throttle - 节流函数

trace - 控制台输出信息

typeOf - 判断数据类型

warning - 控制台输出警告信息

_cloneObj - 深拷贝数据

_deepCopy - 深拷贝数据-递归

_error - 抛出错误信息

_tco - 尾递归优化

_toString - 转字符串

rjs重构

awaitTo - 优化await异常转换

classWeakMap - class-重构WeakMap,使其可以遍历

installModuleClass - class类绑定this指向

promiseAllSettled - 模拟Promise.allSettled

_filter - 数据过滤-不递归

_findName - 查询数组内数据值

_for - 遍历数据

_forEach - 遍历数组数据

_forObject - 遍历对象数据

_interval - 通用计时函数

_stringify - 转字符串

_timeout - class-setTimeout延时函数

_trim - 去掉字符串空格

rank计算

arr2Merger - 简单数组的合并去重

deepMerge - 深层合并对象

getCombine - 从数组中取出n个元素的所有组合

getMaximin - 获取简单一维数组中的最大值

getNameOrKey - 过滤数据查询某一个值的集合 -- filterList重合 - 废弃

getPermutation - 计算数组中所有的排列方式

getRandomArrayElements - 随机获取数组中的元素组合

isArrRepeat - 判断一维数组中是否存在重复元素

locusCircularTimes - 秒针转动一圈的轨迹

mergeJson - 根据标识合并多个单层数组或对象

mergeJsonMixed - 根据标识获取多个单层数组的交集

specPermutation - 二维数组中数组元素的全排列 == 规格 废弃 与arrayToTree相同

_swapArray - 复杂数组数据交换

undefined

business复杂

afreshSetTree - 一维数组生成一次性树结构

arrayToTree - 数组转树结构

filterData - 深度过滤数据

filterList - 递归查询数组数据

findTarget - 遍历获取数组中的对应目标节点

nestedProperty - 嵌套对象处理方法

treeToArray - 递归查询数组

数组处理

arr2Union - 获取数组的并集

arrayToString - 数组转字符串

findForStatic - 根据静态枚举查询对应值

getOneArr - 获取单层级数组 - 浅拷贝

getTreeValueToParentKeys - 根据parentKeys获取值列表

对象处理

getOneObj - 获取单层级对象 - 浅拷贝

柯里化缓存

cacheCalculate - 缓存计算值

cacheFnParams - 缓存函数参数

数据处理

数据转换

_toJson - 转json

formatJsonStr - 格式json字符串

_toNumber - 转数字

_toFixed - 重构toFixed //四舍五入

_toNumFixed - 转数字

随机生成

_seedId - 生成不重复的唯一值-数值型

_keyid - 生成不重复的唯一值-固定字符型

numberRandom - 生成随机数

字符串处理

Cutsubstr - 截取字符串+... 中英文区分

strlen - 计算数据长度

strlenUnit - 转换带单位数据

_compareVersion - 比较字符串版本

_getStr - 获取有效的字符串

数字处理

numberClamp - 限制数值范围

numberComma - 用于分割数字,一般用于格式化金额

numberPad - 补充差值,过滤负数|字符

_float - 浮点数计算

颜色处理

colorHex - RGB颜色转换为16进制

colorRgb - 16进制颜色转为RGB格式

getRandomColor - 获取随机颜色值

时间处理

classEndDate - class-获取截止时间的方法类

formatDurationToFriendly - 秒转换成友好格式 (四舍五入)

getAllLeftTime - class-获取剩余时间的方法类

getEndDateToMonth - 通过月份获取截止时间

getServerTime - 获取服务器时间

getTimeStamp - 获取不同地区的时间戳

parseAboutTime - 解析当前时间的大致差时

getTimeStamp - 设置不同地区的时间戳

endDate - 直接使用-classEndDate

_formatDate - 格式化时间

_getAllDate - 获取时间内所有基础信息

_getDate - 获取时间元数据

_getDateDefaultUnit - 获取默认时间单位

_getMonthDays - 获取某一年某一月的总天数

_isLeapYear - 判断某一年是否是闰年

allLeftTime - 直接使用getAllLeftTime

_parseDate - 日期反向解析

文件处理

clearFileURL - 清除文件路径

downloadBlob - 数据流下载

downloadFile - 下载文件

downloadLink - 地址文件下载

getFileURL - 兼容生成文件路径

linkToBlob - 图片链接转Blob

loadResource - 加载页面资源文件

loadResourceCode - 加载页面代码

loadScript - 加载脚本文件

loadStyle - 加载css样式表文件

preLoadStyle - 预加载link资源配置

reFileName - 重命文件名称

uploadFile - 原生js上传多图

ifs判断处理

checkEmail - 验证邮件

checkPhone - 验证手机

envWxMiniApp - 微信小程序环境环境

getIdCardInfo - 解析身份证信息

getIdCardLastChar - 获取身份证号第18位校验码

getObjVal - 查询嵌套对象的属性

hasObjEqual - 判断两个对象是否相等

hasObjKey - 查询嵌套对象是否具有给定的属性

isAfterIphoneX - 判断是否是iphoneX及之后的机型

isArray - 判断是否是数组数据

isChinese - 判断是否是汉字

isChineseName - 是否是中文名字

isEmptyObject - 是否是空对象

isInteger - 是否是整数

isIphone - 判断是否是phone

isIphoneX - 判断是否是iphoneX和iphoneXS

isNulls - 判断除对象外的空值

isObject - 判断是否是对象

isPromise - 是否是promise

isScreenSzie - 是否是屏幕尺寸-全屏

isString - 是否是字符串类型

isThisBoolean - 过滤非boolean时的默认值设置

isUndefined - 是否为undefined

isValidIDCard - 是否为身份证号

isValidIP - 是否是ip地址

isWechat - 判断是否是微信环境

setObjVal - 设置嵌套对象的属性

_isValue - 判断是有效值

_noValue - 检查给定的值是否为“无值”状态。

富文本数据处理

_regAngle - 替换英文字符为全角字符

_trimSpecial - 去除特殊占位符号

_trimEmoji - 去除表情符号

clearEmptyTags - 去除空标签

regHtmlBreakList - 替换回车换行符

HTTP处理

getStorageSzie - 获取缓存容量

浏览器缓存

Cookies - prott-Cookie集合

cookie - cookie简易版操作

Locals - prott-本地缓存集合

local - 本地缓存简化版

localExpires - 本地+生存周期

Sessions - prott-会话缓存集合

session - Sessions简化版

参数处理

_getParams - 获取URL字符串的参数

_getParamsByName - 根据参数获取链接中的对应值

_getAllParams - 获取Http全部信息

_paramsToString - 对象参数转url字符串

_paramsToSimpleList - 对象完全转换简单列表

_getHttpCodeMsg - 获取http状态码的提示信息

setURLParams - 设置url中参数覆盖

removeURLParameter - 移除URL某个参数

_encode - URL编码转换

_decode - 重构decodeURIComponent

getOneEncode - 获取encodeURIComponent后的字符串(单次判断)

setUrlHttps - 设置链接协议为https

浏览器操作

addXSupport - 兼容X适配-加上viewport-fit=cover

_browser - 获取移动端设备环境类

copyHandler - 复制文本

getNetwork - 移动端获取网络状态

getOrientationStatus - 获取横竖屏状态

readyDOM - 兼容document加载完成事件

scrollBackTop - 回到顶部 - 流畅

versions - 获取移动端设备版本信息

元素处理

createCover - 创建透明蒙层(应用场景:点击触发后其他操作不可触发)

domIsHidden - 是否是隐藏元素

getAllScreen - 获取屏幕screen信息

getClientH - 获取document的可见高度

getClientSize - 根据size获取对应尺寸

getCssStyle - 获取css样式属性

getDocumentBody - 兼容获取body元素

getRectSize - 获取rect边界尺寸

getScrollLeft - 获取滚动条左边界

getScrollTop - 获取滚动条上边界

getSrcollH - 获取元素的整体高度

prefixStyle - 自动添加适配浏览器样式前缀

addClass - 过滤添加class类

hasClass - 判断类名是否存在目标类

removeClass - 从指定元素中移除指定的类名。

_replaceClass - description

事件处理

EventBus - class-事件总线(数组)

stopDefault - 阻止默认事件

stopTouch - 弹窗显示时禁止页面滑动

triggerEvent - 兼容性click元素触发

_off - 解绑事件

_on - 绑定事件

图片处理

downloadIamge - 下载图片

getImgeInfo - 获取图片元素信息

getImgSize - 获取base64图片储存大小

getPixelRatio - 获取canvas渲染的像素倍数

imageLoaded - 处理图片加载完毕

_iosRepairImg - 修复IOS中图片旋转问题

_rotateImg - 旋转图片

图片转码

blobToCanvas - 文件流转Canvas

blobToString - blobToString

canvasToDataURL - canvas转DataURL

dataURLToBlob - dataURL转Blob

dataURLToBuffer - dataURL转Buffer

dataURLToFile - dataURL转File

fileToDataURL - 文件流转DataURL

imageToBlob - 图片链接转Blob

imageToCanvas - 图片链接转canvas

正则处理

babelToFileName - bebel文件名互换

getChinese - 获取字符中的中文字符

regDesensitized - 脱敏函数

regHtmlRepImg - 替换编辑图片标签

WordFirstUper - 单词首字符大写

_telFormat - 手机号格式转换

业务处理

asyncStateErrorMsg - 异步处理错误状态(如有错误,后续不进行请求)

classCountDown - class-倒计时

classWatcherMap - class-监听控制

PageList - 分页处理方法

PollingQuery - 异步轮询

TaskQueue - 任务队列-并发控制器

useStateErrorMsg - hook-封装errMsg的赋值

单元方法

contentTypeList - contentType枚举

devicePixelRatio - devicePixelRatio

document - document

history - history

location - location

navigator - navigator

regColorHex - regColorHex

requestAnimationFrame - requestAnimationFrame

root - 根变量

screen - screen

URL - URL

XMLHttpRequest - XMLHttpRequest

拓展插件库

VUE2拓展

基础拓展

封装了异步,埋点,常用方法 异步以axios为基础,适用于业务中每一个不同类型的框架

异步扩展

饿了么拓展

根据业务中管理后台都是基于elementUI开发,对每一个业务后台进行分析后,封装的通用组件,方法及业务拓展

applyBaseInfo - 2.15.6 以下版本基础信息组件

applyDescriptions - 2.15.6 以上版本基础信息组件

applyDialog - 基础弹窗组件

applyPage - 基础分页组件

applyTable - 基础表格组件

formButton - 表单按钮组件

formCell - 表单单元控件

formItem - 表单控制单元

formPopup - 表单弹窗

pageContainer - 自动计算剩余高度

searchControl - 行内搜索筛选器

searchForm - 搜索列表页面集合组件

apply-upload-button - 上传导入按钮

扩展函数

封装了些业务中的通用处理方案

ele2Extend_util

微信拓展

意见分析

兼容两套UI,因微易本身UI组件库bug太多,功能不具有拓展性,但很多项目有用到,并且其中有对一些业务做的专属组件,所以迫不得已,附加`vant`为辅,虽然可整合,但没啥意义,好处太少
- 如果整合集成在一起,代码融入到新组件库中,那么对于之前的项目而言
	1. 替换之前组件引用,这样改动大,同时容易出错,维护时如果只改一套,就会让原来的出现差异,如此递增下去,差异越大越难改
	2. 组件集成兼容原来的组件库的引用,使效果一致,维护性较之高

小程序拓展

通用库整理,因为小程序部分代码不能放入通用库中,入需使用需按需加载 拥有部分组件,部分业务整合,与风格统一处理

内置方法

wxAuthorize - 提前向用户发起授权请求

wxOpenSetting - 调起客户端小程序设置界面

wxGetSetting - 查询用户的当前设置 有限频

_authorize - 不查询,直接授权

_request - 内置小程序请求

wxLoading - 内置loading提示框

wxTips - 内置提示对话框

wxToast - 内置消息提示框

getImageInfo - 获取图片信息

reportAnalytics - 线上统计请求的错误信息

setRemoteImgInfo - 批量替换远程图片为本地

uploadImage - 上传图片

wxBarLoading - 设置导航栏加载状态

wxClipData - 内置复制内容

wxNavito - 跳转页面

wxSetBarTitle - 设置导航标题

wxSysInfo - 同步获取系统信息

其他扩展

异步扩展

日志管理

单元方法

config配置