aluo-utils
v2.0.0
Published
📦 现代化、高性能的轻量级 TypeScript 工具库
Maintainers
Readme
aluo-utils v2.0
🚀 现代化、轻量级、支持 Tree-shaking 的 TypeScript 工具库。
✨ 特性
- 类型安全:基于 TypeScript 5.x 编写,内置完善的类型定义。
- 模块化:支持按需引入,极小化打包体积。
- 双格式支持:同时输出 ESM 和 CommonJS 格式。
- 功能全面:涵盖校验、DOM、数组、存储、函数工具等。
📦 安装
npm install aluo-utils
# 或
yarn add aluo-utils🔨 使用示例
按需引入 (推荐)
import { isString, debounce, Storage } from 'aluo-utils';
if (isString('hello')) {
console.log('It is a string!');
}
const fn = debounce(() => console.log('debounced!'), 500);
Storage.set('user', { name: 'Moody' }, Date.now() + 3600 * 1000);模块说明
🛡️ 校验模块 (is.ts)
isString,isNumber,isBoolean,isFunction,isObject,isArray,isDate等类型卫兵isEmail,isMobile,isURL业务校验isWeiXin,isIos,isPC环境检测
📁 存储模块 (storage.ts)
Storage.set(key, value, expire?): 存入数据并设置过期时间Storage.get(key): 获取数据,自动检测是否过期
🛠️ 数组模块 (array.ts)
shuffle(arr): 洗牌算法unique(arr): 数组去重arrMax(arr): 最大值arrSort(arr, type): 多样化排序
🎨 字符串模块 (string.ts)
numberToChinese(num): 数字转中文大写colorToRGB(hex, opacity?): 16进制转RGB/RGBAcheckPwd(str): 密码强度检测 (1-4级)
🖱️ DOM 模块 (dom.ts)
scrollToTop(): 平滑回到顶部elenentIsvisbleInViewPort(el): 视口可见性检测injectScript(src): 动态加载 JS 脚本
📄 开源协议
本项目基于 MIT 协议开源。Copyright (c) 2026 Moody.
