@zpxhy/plugins
v1.0.1
Published
xhy自用插件库 - 纯JS工具类,只要支持JavaScript就可以使用
Readme
@zpxhy/plugins
xhy 自用插件库 - 纯 JS 工具类,只要支持 JavaScript 就可以使用。
特性
- ✅ 纯 JavaScript 实现,无依赖
- ✅ 不绑定 Node 或浏览器特性,任何 JS 运行环境可用
- ✅ 提供常用工具方法
安装
npm install @zpxhy/plugins使用方式
// ES 模块
import { XhyUtils, XhyValidator, XhyVersion, md5 } from '@zpxhy/plugins';
// 使用工具类
const formattedDate = XhyUtils.formatDate(new Date(), 'YYYY-MM-DD');
// 使用验证器
const isValidPhone = XhyValidator.isPhone('13800138000');
// 使用版本工具
const isValidVersion = XhyVersion.isValid('1.0.0');
// 使用 md5
const sign = md5('hello world');API 文档
XhyUtils - 工具类
formatDate(date, format)- 格式化日期debounce(func, wait)- 防抖函数throttle(func, limit)- 节流函数deepClone(obj)- 深拷贝
XhyValidator - 验证器类
isEmail(email)- 验证邮箱isPhone(phone)- 验证手机号(中国大陆)isIdCard(idCard)- 验证身份证号(中国大陆)isUrl(url)- 验证 URLisEmpty(value)- 验证是否为空isInRange(value, min, max)- 验证数字范围
md5
md5(str)- 计算字符串的 MD5 值
License
ISC
