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

mr_handle_library

v1.0.9

Published

1

Readme

mr_handle_library.js

Build Status NPM version

安装

安装依赖包 npm:

npm install mr_handle_library

引入

cdn 引入相应版本包:

<script src="https://unpkg.com/[email protected]/lib/mr_handle_library.min.js"></script>

构建

确保使用以下方法获取依赖项:

npm install

构建独立的 JavaScript 文件(lib/mr_handle_library.min.js):

npm run build

运行测试:

npm run test

用法

示列:

import { getStringBiteLength } from 'mr_handle_library';
getStringBiteLength('hello word');

方法说明

分类分层处理相关方法:

  • getClassifyClass(data, currentClassify, isAdd): 获取分类层级.
  • getClassifyData(item): 组装每层数据.
  • getSecondLevel(classifyList, dataCopy, isChild): 获取层级方法.
  • dealNum(data): 处理分类下项目数量 遍历得到每项的层级和数量.
  • dealClassify(classifyList, id, isAdd): 删除不可作为父级的分类.
  • getClassifyItem(classifyList, id): 找到对应 id 的分类数据.
  • etClassifyUpClass(data, id, isSecondLevel = true): 获取上级分类.
  • getClassifyIsLast(data, id): 获取分类是否是末级分类.
  • moveDefaultToFirst(data = []): 移动默认到数据第一项

和业务逻辑无关的模块方法:

  • dateCompatibility(time): 处理字符串时间兼容 ios 问题
  • singleTimeformat(m): 处理单个时间数格式(个位时间前面加 0)
  • getDate(timestamp, state, typeStr = '-'): 获取日期
  • pinyinShortCodeToUpperCase(val): 拼音首字母小写转大写
  • genneratorPickerRange(step, min, max): 生成区间数组
  • conversionTime(t): 分钟换算小时
  • randomWord(max): 获取 0-9a-z 随机数
  • getStr(str, len): 字符串截取
  • validateStrTimeFromdata(str): 验证字符串是不是时间格式
  • setSameDayBeginTime(date): 设置时间为当天的 00:00:00
  • setSameDayEndTime(date): 设置时间为当天的 23:59:59
  • convertUTCTimeToLocalTime(temporaryTime, separator = '-', isShowHMS = true):处理 UTC 时间为当地标准时间
  • getMaxLengthSting(str, maxLength): 处理字符长度(以字节为单位)
  • getStringBiteLength(str): 获取字符串的字节长度(以字节为单位)
  • setImageUrl(imgUrl, ossUrl):处理图片路径域名
  • deepCopy(obj): 数据深拷贝(JSON.parse(JSON.stringify)对方法不生效{a:()=>{}})
  • setMoneyUnit(money, pointIndex = -2): 金额单位转换(保留两位小数

处理特定数据相关模块方法:

  • getExpireType(data): 获取有效期
  • scan(data, cb, prop): 多维数组查找
  • reverseDate(data, keys): 格式化后台日期数据
  • getAllKeys(keys): 获取用户所拥有的所有权限
  • currency(value, decimals = 2): 千分位算法
  • separateImgFromAPI(data): 分离接口返回的官网图片和应用商城轮播图片
  • boxCenter(boxEle, cEle): 遍历、居中使用(该方法只用于 inline-block,这很难形容,有好的形容方式请帮我修改或补充,谢谢 )
  • getStyle(element, property): 获取元素的属性
  • toFixed(numberValue, len = 2, isNumber = false): 保留小数处理
  • echartsHandle(echartsDta): echarts 操作栏处理
  • getPayments(data): 获取支付方式、金额组合信息
  • initData(that): 初始化 data
  • getImgArr(img): 格式化字符串
  • uuidCreate(len, radix): js 生成 uuid - 无大写模式

处理特定枚举相关数据,相关的模块方法:

  • getTimeMode(data): 获取套餐类型.
  • getBillSource(source): 获取单据来源.
  • getPayImage(data): 收银端结算图片.