utilsall
v1.0.2
Published
common utils
Downloads
1
Readme
utilsall
description: 提供常用的 utils
install
npm i utilsall
use
1
<script src="https://cdn.jsdelivr.net/npm/utilsall/dist/index.umd.js"></script>
<script>
console.log(window.VUtils);
const { isPhone, isCard } = window.VUtils;
console.log(isPhone(15023509833)); // true
console.log(isCard(0)); // false
</script>
2
import { isQQ, getType } from "utilsall";
console.log(isQQ(2323333339)); // true
console.log(getType({})); // object
API
- 校验
- isCard: (data: string) => 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 对象