1.0.10 • Published 3 years ago
wjs-utils v1.0.10
wjs-utils⚡
安装 💡
yarn add wjs-utilsor
npm install wjs-utils使用 🌲
import utils from "wjs-utils";
utils.isEmail("aaa@123.com")or
import { isEmail } from "wjs-utils";
isEmail("aaa@123.com")or
const utils = require("wjs-utils");持续更新中 ~ 🚀🚀🚀
isEmail(email) ⇒ boolean
判断是否为邮箱
| Param | Type | Description |
|---|---|---|
| string |
Example
isEmail("aaa@qq.com") // trueExample
isEmail("aaqq.com") // falseisPhone(phone) ⇒ boolean
判断是否为手机号码(最宽松)
| Param | Type |
|---|---|
| phone | number | string |
Example
isPhone(13541231213) //trueExample
isPhone(123) //falseisIdCard(idcard) ⇒ boolean
判断是否为身份证号码(支持一代/二代)
| Param | Type |
|---|---|
| idcard | string | number |
Example
isIdCard(510902198910124421) // trueExample
isIdCard(123) // falsesleep(time) ⇒ Promise
延迟多少秒后继续执行
| Param | Type |
|---|---|
| time | number |
Example
sleep(1)formatUrl(url) ⇒ Object
解析url参数为object
| Param | Type |
|---|---|
| url | string |
Example
formatUrl("http://www.baidu.com?a=1&b=aaa") // {a:'1',b:'aaa'}Example
formatUrl("http://www.baidu.com?a=1&a=2&b=3&b=4") // { a: ["1", "2"], b: ["3", "4"]}saveBlobFile(blob, param1)
保存文件
| Param | Type |
|---|---|
| blob | * |
| param1 | * |
Author
wjs email:imwangxuan@gmail.com