@utools/universal
v0.0.58
Published
[![npm](https://img.shields.io/npm/v/@utools/universal.svg)](https://www.npmjs.com/package/@utools/universal) [![npm](https://img.shields.io/npm/dm/@utools/universal.svg)](https://www.npmjs.com/package/@utools/universal) ![GitHub stars](https://img.shie
Downloads
31
Readme
前端通用函数封装 universal
@utools/universal
封装了常用了工具函数,包括dom
、cookie
、storage
、url
、date
、string
、array
、object
、number
、function
、browser
、device
、image
、file
、math
、regexp
、validate
、color
、other
等等,满足你的日常开发需求。
详细请参考文档
安装
npm i @utools/universal
快速上手
通用正则匹配
判断是否为16进制颜色,rgb 或 rgba
import { isColor } from '@utools/universal'
console.log(isColor("#fff")); // true
console.log(isColor("rgba(255,255,200)")); // false
console.log(isColor("rgba(255,255,200,1)")); // true
判断是否为正确的年月日
import { isValidDataTime } from '@utools/universal'
console.log(isValidDataTime(('2019-10-100'))) // false
console.log(isValidDataTime(('2019-10-10'))) // true
console.log(isValidDataTime(('2019-02-28'))) // true
console.log(isValidDataTime(('2019-02-29'))) // false
判断是否为邮箱地址
import { isEmail } from '@utools/universal'
console.log(isEmail('[email protected]')); //true
console.log(isEmail('q23gmail.com')); //false
console.log(isEmail('[email protected]')); //true
console.log(isEmail('[email protected]')); //true
判断是否为手机号码
import { isTelPhoneNum } from '@utools/universal'
console.log(isTelPhoneNum("12345678901")); // false
console.log(isTelPhoneNum("18171123123")); // true
判断是否为身份证号
import { isIdCard } from '@utools/universal'
console.log(isIdCard("430822197406220016")); // true
console.log(isIdCard("43082219740622001x")); // true
判断是否为座机号
import { isLandlineNum } from '@utools/universal'
console.log(isLandlineNum("0755-12345678")); //true
console.log(isLandlineNum("0345-12345678")); // true
console.log(isLandlineNum("x755-12345678")); // false
判断是否为邮政编码
import { isZipCode } from '@utools/universal'
console.log(isZipCode("123456")); // true
console.log(isZipCode("12345")); // false
console.log(isZipCode("832901")); // true
判断是否为合法微信号
import { isWeChat } from '@utools/universal'
console.log(isWeChat("123456")); // false
console.log(isWeChat("12345")); // false
console.log(isWeChat("navalism1")); // true
console.log(isWeChat("cooo1")); // false