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

liao_modules

v2.4.1

Published

数组、字符串、数字、缓存等...工具类及公共组件库

Downloads

4

Readme

liao_modules

用于操作数组、对象、数字、字符串、金钱、时间等等的时间工具类...

二次封装sessionStorage,localStorage可对浏览器缓存实现增、删、改基本操作...

封装部分公共组件(词云图等...)。

# install dependencies
npm install liao_modules
	

[TOC]

工具类

LiaoArrayUtil(数组工具类)

| 方法 | 注释 | 入参 | 出参 | | --------------- | -------------------------------------------------- | ------------------------ | ---------------------- | | getIntersection | 得到两个数组的交集, 两个数组的元素为数值或字符串 | 数组1、数组2 | 两个数组的交集 | | getUnion | 得到两个数组的并集, 两个数组的元素为数值或字符串 | 数组1、数组2 | 两个数组的并集 | | hasOneOf | 判断要查询的数组是否至少有一个元素包含在目标数组中 | 目标数组、需要查询的数组 | true-包含 false-不包含 | | isEmpty | 判断数组是否为空 | 需要判断的数组 | true-是 false-否 | | splitByProp | 根据特定字段分组 | 需要分组数组、字段名 | 返回新的数组 |

LiaoCacheUtil(缓存工具类)

| 方法 | 注释 | 入参 | 出参 | | ------------------- | ------------------------------------------------------- | ---------- | ----------------------------------------- | | getSessionObject | 获取指定key的sessionStorage,经过JSON序列化。存在则覆盖 | key | 若存在返回JSON.parse(value),否则返回null | | setSessionObject | 设置指定key的sessionStorage,经过JSON序列化。存在则覆盖 | key、value | // | | removeSessionObject | 删除指定key的sessionStorage | key | // | | getLocalObject | 获取指定key的localStorage,经过JSON序列化。存在则覆盖 | key | 若存在返回JSON.parse(value),否则返回null | | setLocalObject | 设置指定key的localStorage,经过JSON序列化。存在则覆盖 | key、value | // | | removeLocalObject | 删除指定key的localStorage | key | // |

LiaoCalcUtil(计算工具类)

| 方法 | 注释 | 入参 | 出参 | | --------------- | ------------------- | ------------------------- | -------------- | | calcColumnWidth | 表格列宽转换公式 | 字符长度、是否是排序字段 | 计算后的列宽值 | | plus | 加法计算(接受N参) | 数字1、数字2、......数字N | 数字 | | minus | 减法计算(接受N参) | 数字1、数字2、......数字N | 数字 | | times | 乘法计算(接受N参) | 数字1、数字2、......数字N | 数字 | | divide | 除法计算(接受N参) | 数字1、数字2、......数字N | 数字 | | round | 四舍五入取N位小数 | 数字、取舍的小数点位数 | 数字 |

LiaoEncryptUtil(加密工具类)

| 方法 | 注释 | 入参 | 出参 | | ------------ | ----------- | ------------------------------------------------------ | --------------- | | MD5 | MD5算法加密 | 源 | string | | RSA | RSA算法加密 | 待加密明文、公钥、加密后输出格式、待加密内容的编码方式 | Buffer & string | | SM2Encrypt | SM2算法加密 | 加密数据、公钥、加密模式 | string | | SM2DoDecrypt | SM2算法解密 | 解密数据、公钥、加密模式 | string | | hmac | hmac加密 | 加密类型、加密数据、密钥 | base64 |

LiaoFileUtil(文件工具类)

| 方法 | 注释 | 入参 | 出参 | | ------------------- | ---------------------------------- | ------------- | ------------- | | dataStreamCovertPdf | pdf数据流转为pdf文件并新开窗口展示 | 二进制数据流 | // | | Pdfbase64ToBlob | PDFbase64数据转换为blob | Pdfbase64Data | Pdf格式的blob | | htmlBase64 | 将html转换为base64 | dom | base64 |

LiaoMoneyUtil(金钱工具类)

| 方法 | 注释 | 入参 | 出参 | | -------------- | ---------------------------- | -------------- | ------ | | num2ChineseNum | 将十位数以内金额转为大写中文 | 需要转换的金额 | string | | toDecimalSplit | 强制保留小数(截取) | 金额、保留位数 | any | | toDecimal | 强制保留小数,四舍五入 | 金额、保留位数 | string |

LiaoNumberUtil(数字工具类)

| 方法 | 注释 | 入参 | 出参 | | ---------- | ------------------------ | ------------ | ------------ | | toDecimal2 | 四舍五入强制保留两位小数 | 需保留的小数 | 处理后的小数 |

LiaoObjectUtil(对象工具类)

| 方法 | 注释 | 入参 | 出参 | | ------------- | ------------------------------------------------------ | -------------------------- | -------- | | diff | 比较两个object,并返回不同时的旧值和新值 | 新对象、老对象 | object | | getTypeByObj | 获取数据类型 | 待判断的数据 | 数据类型 | | judgeType | js数据类型判断 | 等待判断的数据、判断的类型 | boolean | | isEmptyObject | 判断是否是空对象 | object | boolean | | isEmpty | 判断是否是空 | object | boolean | | isObject | 是否为对象类型 | 等待判断的数据 | boolean | | deepClone | 深拷贝 | object | object | | equals | 比较两个object是否相同 | object1、object2 | boolean | | objEqual | 比较两个对象是否相等(这两个对象的值只能是数字或字符串) | object1、object2 | boolean | | pick | 挑选对象部分属性形成一个新对象 | 目标对象、属性列表 | object |

LiaoStringUtil(字符串工具类)

| 方法 | 注释 | 入参 | 出参 | | ------------- | -------------------- | ------ | ------- | | isBlank | 字符串是否为空 | 字符串 | boolean | | isDecimals | 是否为小数 | 字符串 | boolean | | getRandom | 生成x位16进制字符串 | number | string | | base64ToHEX | base64转16进制字符串 | string | string | | hexToBase64 | 16进制字符串转base64 | string | string | | base64ToBytes | base64转bytes | string | bytes | | utf8ToBase64 | bytes转base64 | bytes | string |

LiaoToolUtil(工具工具类)

| 方法 | 注释 | 入参 | 出参 | | -------------- | ------------------ | --------------------------------------------------- | ---------------- | | getExplorer | 获取当前浏览器名称 | // | string | | getQueryString | 获取url参数 | 参数名 | 参数值 | | debounce | 函数防抖封装 | 需要防抖的函数、时间间隔(毫秒)、是否先执行后防抖 | 防抖处理后的函数 | | throttle | 函数节流封装 | 需要节流的函数、时间间隔(毫秒)、 是否先执行后节流 | 节流处理后的函数 |