util-helpers 4.3.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/util-helpers.js +201 -23
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/calculateCursorPosition.js +62 -0
- package/esm/formatBankCard.js +1 -2
- package/esm/formatMobile.js +45 -0
- package/esm/index.js +3 -0
- package/esm/isHMCard.js +12 -0
- package/esm/isIdCard.js +1 -1
- package/esm/isTWCard.js +6 -0
- package/esm/normalizeString.js +1 -0
- package/esm/parseIdCard.js +34 -14
- package/esm/safeDate.js +41 -0
- package/esm/setDataURLPrefix.js +1 -2
- package/esm/validatePassword.js +17 -1
- package/lib/calculateCursorPosition.js +73 -0
- package/lib/formatBankCard.js +1 -2
- package/lib/formatMobile.js +55 -0
- package/lib/index.js +24 -0
- package/lib/isHMCard.js +12 -0
- package/lib/isIdCard.js +1 -1
- package/lib/isTWCard.js +6 -0
- package/lib/normalizeString.js +1 -0
- package/lib/parseIdCard.js +34 -14
- package/lib/safeDate.js +57 -0
- package/lib/setDataURLPrefix.js +1 -2
- package/lib/validatePassword.js +17 -1
- package/package.json +1 -1
- package/types/calculateCursorPosition.d.ts +25 -0
- package/types/formatMobile.d.ts +27 -0
- package/types/index.d.ts +3 -0
- package/types/isHMCard.d.ts +12 -0
- package/types/isTWCard.d.ts +6 -0
- package/types/normalizeString.d.ts +1 -0
- package/types/parseIdCard.d.ts +84 -25
- package/types/safeDate.d.ts +22 -0
- package/types/setDataURLPrefix.d.ts +1 -2
- package/types/validatePassword.d.ts +58 -12
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ yarn add util-helpers
|
|
|
20
20
|
|
|
21
21
|
在浏览器中使用 `script` 标签直接引入文件,并使用全局变量 `utilHelpers` 。
|
|
22
22
|
|
|
23
|
-
`npm` 包的 `util-helpers/dist` 目录下提供了 `util-helpers.js` 以及 `util-helpers.min.js`。你也可以通过 [UNPKG](https://unpkg.com/util-helpers@latest/dist/)
|
|
23
|
+
`npm` 包的 `util-helpers/dist` 目录下提供了 `util-helpers.js` 以及 `util-helpers.min.js`。你也可以通过 [UNPKG](https://unpkg.com/util-helpers@latest/dist/) 下载到本地进行使用。或者直接使用 [UNPKG 线上版本](https://unpkg.com/util-helpers@latest/dist/util-helpers.min.js)<sup> _注意版本_ </sup>。
|
|
24
24
|
|
|
25
25
|
## 示例
|
|
26
26
|
|
|
@@ -47,11 +47,14 @@ formatMoney('1000'); // => 1,000.00
|
|
|
47
47
|
- [blobToDataURL](https://doly-dev.github.io/util-helpers/module-Processor.html#.blobToDataURL) - 将 Blob 或 File 对象转成 data:URL 格式的 Base64 字符串
|
|
48
48
|
- [bytesToSize](https://doly-dev.github.io/util-helpers/module-Processor.html#.bytesToSize) - 字节转换为存储单位
|
|
49
49
|
- [dataURLToBlob](https://doly-dev.github.io/util-helpers/module-Processor.html#.dataURLToBlob) - 将 DataURL 转为 Blob 对象
|
|
50
|
-
- [formatMoney](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMoney) -
|
|
51
|
-
- [
|
|
50
|
+
- [formatMoney](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMoney) - 格式化金额
|
|
51
|
+
- [formatMobile](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMobile) - 格式化手机号码
|
|
52
|
+
- [formatBankCard](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatBankCard) - 格式化银行卡
|
|
53
|
+
- [normalizeString](https://doly-dev.github.io/util-helpers/module-Processor.html#.normalizeString) - 规整化字符串,如果值为 `undefined` `null` 转为 '',如果不是字符串类型则转为字符串
|
|
52
54
|
- [numberToChinese](https://doly-dev.github.io/util-helpers/module-Processor.html#.numberToChinese) - 数字转中文数字
|
|
53
55
|
- [parseIdCard](https://doly-dev.github.io/util-helpers/module-Processor.html#.parseIdCard) - 解析身份证号码
|
|
54
56
|
- [replaceChar](https://doly-dev.github.io/util-helpers/module-Processor.html#.replaceChar) - 替换字符,应用场景如:脱敏
|
|
57
|
+
- [safeDate](https://doly-dev.github.io/util-helpers/module-Processor.html#.safeDate) - 创建一个 Date 实例,同 new Date
|
|
55
58
|
- [setDataURLPrefix](https://doly-dev.github.io/util-helpers/module-Processor.html#.setDataURLPrefix) - 设置 DataURL 前缀、MIME 类型、base64 标识
|
|
56
59
|
- 数据验证
|
|
57
60
|
- [isMobile](https://doly-dev.github.io/util-helpers/module-Validator.html#.isMobile) - 手机号码
|
|
@@ -76,7 +79,8 @@ formatMoney('1000'); // => 1,000.00
|
|
|
76
79
|
- [isBusinessLicense](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBusinessLicense) - 营业执照,也叫工商注册号
|
|
77
80
|
- [validatePassword](https://doly-dev.github.io/util-helpers/module-Validator.html#.validatePassword) - 验证密码
|
|
78
81
|
- 其他
|
|
79
|
-
- [
|
|
82
|
+
- [calculateCursorPosition](https://doly-dev.github.io/util-helpers/module-Other.html#.calculateCursorPosition) - 等待时间返回 Promise
|
|
83
|
+
- [waitTime](https://doly-dev.github.io/util-helpers/module-Other.html#.waitTime) - 计算光标位置
|
|
80
84
|
|
|
81
85
|
## 精选第三方工具库
|
|
82
86
|
|
|
@@ -93,7 +97,6 @@ formatMoney('1000'); // => 1,000.00
|
|
|
93
97
|
- [store2] - 丰富了 localStorage 和 sessionStorage 功能(JSON,命名空间,扩展等)
|
|
94
98
|
- [uuid] - 生成通用唯一识别码(Universally Unique Identifier)
|
|
95
99
|
- [JSZip] - 创建、读取和编辑 zip 文件
|
|
96
|
-
<!-- - [data-urls] - 根据 WHATWG Fetch 标准解析 Data URLs -->
|
|
97
100
|
|
|
98
101
|
[lodash]: https://www.npmjs.com/package/lodash
|
|
99
102
|
[query-string]: https://www.npmjs.com/package/query-string
|