util-helpers 4.13.0 → 4.14.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 +16 -6
- package/dist/util-helpers.js +935 -536
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/blobToDataURL.js +2 -4
- package/esm/bytesToSize.js +13 -5
- package/esm/calculateCursorPosition.js +7 -12
- package/esm/dataURLToBlob.js +2 -5
- package/esm/divide.js +9 -13
- package/esm/findTreeNode.js +66 -0
- package/esm/findTreeSelect.js +80 -0
- package/esm/formatBankCard.js +11 -11
- package/esm/formatMobile.js +11 -14
- package/esm/formatMoney.js +24 -35
- package/esm/index.js +9 -4
- package/esm/isBankCard.js +9 -13
- package/esm/isBusinessLicense.js +19 -20
- package/esm/isChinese.js +6 -6
- package/esm/isEmail.js +3 -3
- package/esm/isHMCard.js +3 -3
- package/esm/isIPv4.js +3 -3
- package/esm/isIPv6.js +3 -3
- package/esm/isIdCard.js +9 -17
- package/esm/isMobile.js +3 -3
- package/esm/isPassport.js +3 -3
- package/esm/isPassword.js +6 -7
- package/esm/isPostcode.js +3 -3
- package/esm/isPromiseLike.js +0 -2
- package/esm/isQQ.js +3 -3
- package/esm/isSocialCreditCode.js +29 -28
- package/esm/isSwiftCode.js +1 -2
- package/esm/isTWCard.js +6 -7
- package/esm/isTelephone.js +3 -3
- package/esm/isUrl.js +7 -3
- package/esm/isVehicle.js +3 -3
- package/esm/isWX.js +3 -3
- package/esm/listToTree.js +122 -0
- package/esm/minus.js +7 -11
- package/esm/normalizeString.js +1 -3
- package/esm/numberToChinese.js +43 -52
- package/esm/padZero.js +1 -5
- package/esm/parseIdCard.js +27 -23
- package/esm/plus.js +7 -11
- package/esm/randomString.js +2 -8
- package/esm/replaceChar.js +11 -16
- package/esm/round.js +4 -5
- package/esm/safeDate.js +5 -7
- package/esm/setDataURLPrefix.js +0 -1
- package/esm/strlen.js +1 -5
- package/esm/times.js +7 -11
- package/esm/transformFieldNames.doc.js +34 -0
- package/esm/transformFieldNames.js +98 -0
- package/esm/transformFieldNames.type.js +19 -0
- package/esm/treeToList.js +88 -0
- package/esm/utils/config.js +3 -3
- package/esm/utils/constants.js +2 -2
- package/esm/utils/convertToString.js +1 -2
- package/esm/utils/devWarn.js +1 -3
- package/esm/utils/math.util.js +20 -29
- package/esm/utils/type/index.js +1 -1
- package/esm/utils/type/isArguments.js +1 -2
- package/esm/utils/type/isArray.js +1 -2
- package/esm/utils/type/isBoolean.js +1 -2
- package/esm/utils/type/isDate.js +1 -2
- package/esm/utils/type/isError.js +1 -2
- package/esm/utils/type/isFunction.js +1 -2
- package/esm/utils/type/isMap.js +1 -2
- package/esm/utils/type/isNaN.js +1 -2
- package/esm/utils/type/isNil.js +1 -2
- package/esm/utils/type/isNull.js +0 -1
- package/esm/utils/type/isNumber.js +1 -2
- package/esm/utils/type/isObject.js +0 -3
- package/esm/utils/type/isRegExp.js +1 -2
- package/esm/utils/type/isSet.js +1 -2
- package/esm/utils/type/isString.js +1 -2
- package/esm/utils/type/isSymbol.js +1 -2
- package/esm/utils/type/isType.js +1 -2
- package/esm/utils/type/isUndefined.js +0 -1
- package/esm/utils/type/isWeakMap.js +1 -2
- package/esm/utils/type/isWeakSet.js +1 -2
- package/esm/validatePassword.js +27 -50
- package/esm/waitTime.js +0 -1
- package/lib/blobToDataURL.js +2 -5
- package/lib/bytesToSize.js +13 -6
- package/lib/calculateCursorPosition.js +4 -13
- package/lib/dataURLToBlob.js +2 -6
- package/lib/divide.js +8 -22
- package/lib/findTreeNode.js +76 -0
- package/lib/findTreeSelect.js +86 -0
- package/lib/formatBankCard.js +10 -13
- package/lib/formatMobile.js +10 -16
- package/lib/formatMoney.js +25 -47
- package/lib/index.js +115 -126
- package/lib/isBankCard.js +7 -15
- package/lib/isBusinessLicense.js +17 -22
- package/lib/isChinese.js +6 -9
- package/lib/isEmail.js +1 -5
- package/lib/isHMCard.js +1 -5
- package/lib/isIPv4.js +1 -5
- package/lib/isIPv6.js +1 -5
- package/lib/isIdCard.js +7 -19
- package/lib/isMobile.js +1 -5
- package/lib/isPassport.js +1 -5
- package/lib/isPassword.js +5 -9
- package/lib/isPostcode.js +1 -5
- package/lib/isPromiseLike.js +1 -4
- package/lib/isQQ.js +1 -5
- package/lib/isSocialCreditCode.js +27 -30
- package/lib/isSwiftCode.js +1 -5
- package/lib/isTWCard.js +4 -9
- package/lib/isTelephone.js +1 -5
- package/lib/isUrl.js +5 -5
- package/lib/isVehicle.js +1 -5
- package/lib/isWX.js +1 -5
- package/lib/listToTree.js +131 -0
- package/lib/minus.js +6 -20
- package/lib/normalizeString.js +0 -6
- package/lib/numberToChinese.js +41 -55
- package/lib/padZero.js +0 -7
- package/lib/parseIdCard.js +30 -29
- package/lib/plus.js +6 -20
- package/lib/randomString.js +2 -8
- package/lib/replaceChar.js +10 -18
- package/lib/round.js +3 -9
- package/lib/safeDate.js +4 -13
- package/lib/setDataURLPrefix.js +0 -2
- package/lib/strlen.js +0 -7
- package/lib/times.js +6 -18
- package/lib/transformFieldNames.doc.js +41 -0
- package/lib/transformFieldNames.js +104 -0
- package/lib/transformFieldNames.type.js +5 -0
- package/lib/treeToList.js +96 -0
- package/lib/utils/config.js +8 -7
- package/lib/utils/constants.js +2 -2
- package/lib/utils/convertToString.js +0 -4
- package/lib/utils/devWarn.js +0 -4
- package/lib/utils/math.util.js +23 -45
- package/lib/utils/type/index.js +20 -39
- package/lib/utils/type/isArguments.js +0 -4
- package/lib/utils/type/isArray.js +0 -4
- package/lib/utils/type/isBoolean.js +0 -4
- package/lib/utils/type/isDate.js +0 -4
- package/lib/utils/type/isError.js +0 -4
- package/lib/utils/type/isFunction.js +0 -4
- package/lib/utils/type/isMap.js +0 -4
- package/lib/utils/type/isNaN.js +0 -4
- package/lib/utils/type/isNil.js +0 -5
- package/lib/utils/type/isNull.js +0 -2
- package/lib/utils/type/isNumber.js +0 -4
- package/lib/utils/type/isObject.js +1 -5
- package/lib/utils/type/isRegExp.js +0 -4
- package/lib/utils/type/isSet.js +0 -4
- package/lib/utils/type/isString.js +0 -4
- package/lib/utils/type/isSymbol.js +0 -4
- package/lib/utils/type/isType.js +1 -2
- package/lib/utils/type/isUndefined.js +0 -2
- package/lib/utils/type/isWeakMap.js +0 -4
- package/lib/utils/type/isWeakSet.js +0 -4
- package/lib/validatePassword.js +27 -53
- package/lib/waitTime.js +0 -2
- package/package.json +9 -7
- package/types/bytesToSize.d.ts +9 -1
- package/types/findTreeNode.d.ts +26 -0
- package/types/findTreeSelect.d.ts +26 -0
- package/types/formatBankCard.d.ts +3 -3
- package/types/formatMobile.d.ts +4 -4
- package/types/index.d.ts +5 -0
- package/types/isIdCard.d.ts +2 -0
- package/types/isUrl.d.ts +2 -0
- package/types/listToTree.d.ts +41 -0
- package/types/transformFieldNames.d.ts +34 -0
- package/types/transformFieldNames.type.d.ts +2 -0
- package/types/treeToList.d.ts +20 -0
- package/types/utils/config.d.ts +1 -2
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
[util-helpers](https://doly-dev.github.io/util-helpers/index.html) 是一个基于业务场景的工具方法库。
|
|
6
6
|
|
|
7
|
+
[点击查看在线文档](https://doly-dev.github.io/util-helpers/index.html)。
|
|
8
|
+
|
|
7
9
|
## 使用
|
|
8
10
|
|
|
9
11
|
### `es` 或 `node` 开发环境
|
|
@@ -29,12 +31,12 @@ yarn add util-helpers
|
|
|
29
31
|
## 示例
|
|
30
32
|
|
|
31
33
|
```javascript
|
|
32
|
-
import {
|
|
34
|
+
import { formatMoney, formatBankCard } from 'util-helpers';
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
formatBankCard('6228480402564890018', { char: '-' }); // => 6228-4804-0256-4890-018
|
|
36
|
+
formatMoney('1000'); // 1,000.00
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
formatBankCard('6228480402564890018'); // 6228 4804 0256 4890 018
|
|
39
|
+
formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-4890-018
|
|
38
40
|
```
|
|
39
41
|
|
|
40
42
|
## 文档
|
|
@@ -54,6 +56,7 @@ formatMoney('1000'); // => 1,000.00
|
|
|
54
56
|
- [formatMoney](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMoney) - 格式化金额
|
|
55
57
|
- [formatMobile](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatMobile) - 格式化手机号码
|
|
56
58
|
- [formatBankCard](https://doly-dev.github.io/util-helpers/module-Processor.html#.formatBankCard) - 格式化银行卡
|
|
59
|
+
- [listToTree](https://doly-dev.github.io/util-helpers/module-Processor.html#.listToTree) - 列表数据转树结构
|
|
57
60
|
- [normalizeString](https://doly-dev.github.io/util-helpers/module-Processor.html#.normalizeString) - 规整化字符串,如果值为 `undefined` `null` 转为 '',如果不是字符串类型则转为字符串
|
|
58
61
|
- [numberToChinese](https://doly-dev.github.io/util-helpers/module-Processor.html#.numberToChinese) - 数字转中文数字
|
|
59
62
|
- [padZero](https://doly-dev.github.io/util-helpers/module-Processor.html#.padZero) - 前置补零
|
|
@@ -61,6 +64,8 @@ formatMoney('1000'); // => 1,000.00
|
|
|
61
64
|
- [replaceChar](https://doly-dev.github.io/util-helpers/module-Processor.html#.replaceChar) - 替换字符,应用场景如:脱敏
|
|
62
65
|
- [safeDate](https://doly-dev.github.io/util-helpers/module-Processor.html#.safeDate) - 创建一个 Date 实例,同 new Date
|
|
63
66
|
- [setDataURLPrefix](https://doly-dev.github.io/util-helpers/module-Processor.html#.setDataURLPrefix) - 设置 DataURL 前缀、MIME 类型、base64 标识
|
|
67
|
+
- [transformFieldNames](https://doly-dev.github.io/util-helpers/module-Processor.html#.transformFieldNames) - 转换字段名
|
|
68
|
+
- [treeToList](https://doly-dev.github.io/util-helpers/module-Processor.html#.treeToList) - 树结构转列表数据
|
|
64
69
|
- 数据验证
|
|
65
70
|
- [isMobile](https://doly-dev.github.io/util-helpers/module-Validator.html#.isMobile) - 手机号码
|
|
66
71
|
- [isTelephone](https://doly-dev.github.io/util-helpers/module-Validator.html#.isTelephone) - 固定电话
|
|
@@ -86,6 +91,8 @@ formatMoney('1000'); // => 1,000.00
|
|
|
86
91
|
- [validatePassword](https://doly-dev.github.io/util-helpers/module-Validator.html#.validatePassword) - 验证密码
|
|
87
92
|
- 其他
|
|
88
93
|
- [calculateCursorPosition](https://doly-dev.github.io/util-helpers/module-Other.html#.calculateCursorPosition) - 计算光标位置
|
|
94
|
+
- [findTreeNode](https://doly-dev.github.io/util-helpers/module-Other.html#.findTreeNode) - 查找树结构数据节点
|
|
95
|
+
- [findTreeSelect](https://doly-dev.github.io/util-helpers/module-Other.html#.findTreeSelect) - 查找包含当前节点的所有父级节点
|
|
89
96
|
- [randomString](https://doly-dev.github.io/util-helpers/module-Other.html#.randomString) - 随机字符串
|
|
90
97
|
- [strlen](https://doly-dev.github.io/util-helpers/module-Other.html#.strlen) - 字符长度
|
|
91
98
|
- [waitTime](https://doly-dev.github.io/util-helpers/module-Other.html#.waitTime) - 等待时间返回 Promise
|
|
@@ -120,13 +127,16 @@ formatMoney('1000'); // => 1,000.00
|
|
|
120
127
|
[store2]: https://www.npmjs.com/package/store2
|
|
121
128
|
[uuid]: https://www.npmjs.com/package/uuid
|
|
122
129
|
[jszip]: https://www.npmjs.com/package/jszip
|
|
123
|
-
[data-urls]: https://www.npmjs.com/package/data-urls
|
|
124
130
|
[npm]: https://img.shields.io/npm/v/util-helpers.svg
|
|
125
131
|
[npm-url]: https://npmjs.com/package/util-helpers
|
|
126
|
-
[what is commitlint]: https://github.com/conventional-changelog/commitlint#what-is-commitlint
|
|
127
132
|
[ua-parser-js]: https://www.npmjs.com/package/ua-parser-js
|
|
133
|
+
|
|
134
|
+
<!--
|
|
135
|
+
[data-urls]: https://www.npmjs.com/package/data-urls
|
|
136
|
+
[what is commitlint]: https://github.com/conventional-changelog/commitlint#what-is-commitlint
|
|
128
137
|
[numeral]: http://numeraljs.com/
|
|
129
138
|
[rxjs]: https://www.npmjs.com/package/rxjs
|
|
130
139
|
[immutable]: https://www.npmjs.com/package/immutable
|
|
131
140
|
[classnames]: https://www.npmjs.com/package/classnames
|
|
132
141
|
[ramda]: https://www.npmjs.com/package/ramda
|
|
142
|
+
-->
|