@vbs/utils
v1.2.9
Published
Team front end tool library
Downloads
7
Readme
VUtils
Team front end tool library
Install
npm i @vbs/utils -S
Use
Mode 1
<script src="//cdn.jsdelivr.net/npm/@vbs/utils/dist/index.umd.js"></script>
<script>
console.log(window.VUtils);
const { isQQ, getType } = window.VUtils;
console.log(isQQ(2323333339)); // true
console.log(isQQ(1000)); // false
console.log(getType(true)); // boolean
console.log(getType(0)); // number
</script>
Mode 2
<script type="module">
import { isQQ, getType } = '../dist/index.esm.js';
console.log(isQQ(2323333339)); // true
console.log(isQQ(1000)); // false
console.log(getType(true)); // boolean
console.log(getType(0)); // number
</script>
Mode 3
import { isQQ, getType } from "@vbs/utils";
console.log(isQQ(2323333339)); // true
console.log(isQQ(1000)); // false
console.log(getType(true)); // boolean
console.log(getType(0)); // number
API
- 校验
- isQQ: (data: string | number) => boolean 校验是否是 QQ 号
- isPhone: (data: string | number) => boolean 校验是否是手机号
- isIDCard: (data: string) => boolean 校验是否是身份证号
- isEmail: (data: string) => boolean 校验是否是邮箱
- isBankCard: (data: string|number) => boolean 校验是否是银行卡
- isName: (data: string, type: "CN" | "EN") => boolean 校验是否是姓名
- 类型
- getType: (data: unknown) => string 获取数据类型
- 方法
- compressImage: (file: File, quality = 1) => Promise<File> | Error 压缩图片
- parseUrl: (url: string) => object | null 获取 URL 的相关对象
- dataURLtoBlob: (dataURL: string) => Blob | null 将 Base64 字符串转为 Blob 对象
- dataURLtoFile: (dataURL: string, fileName: string) => File | null 将 Base64 字符串转为 File 对象
- 函数
- cloneDeep: (data: Array | Record<string | number, unknown>) => Array | Record<string | number, unknown>