util-helpers 4.16.2 → 4.17.1

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.
Files changed (259) hide show
  1. package/dist/util-helpers.js +1600 -4039
  2. package/dist/util-helpers.js.map +1 -1
  3. package/dist/util-helpers.min.js +1 -1
  4. package/dist/util-helpers.min.js.map +1 -1
  5. package/esm/ajax.js +50 -146
  6. package/esm/blobToDataURL.js +4 -34
  7. package/esm/bytesToSize.js +12 -37
  8. package/esm/calculateCursorPosition.js +30 -52
  9. package/esm/dataURLToBlob.js +14 -28
  10. package/esm/divide.js +24 -48
  11. package/esm/download.js +83 -164
  12. package/esm/fileReader.js +18 -64
  13. package/esm/filterTree.js +25 -55
  14. package/esm/findTreeNode.js +39 -67
  15. package/esm/findTreeNodes.js +35 -66
  16. package/esm/findTreeSelect.js +38 -74
  17. package/esm/formatBankCard.js +13 -43
  18. package/esm/formatMobile.js +17 -43
  19. package/esm/formatMoney.js +59 -139
  20. package/esm/index.js +55 -130
  21. package/esm/isBankCard.js +22 -57
  22. package/esm/isBusinessLicense.js +32 -78
  23. package/esm/isChinese.js +23 -66
  24. package/esm/isEmail.js +6 -21
  25. package/esm/isHMCard.js +5 -28
  26. package/esm/isIPv4.js +5 -22
  27. package/esm/isIPv6.js +5 -36
  28. package/esm/isIdCard.js +27 -66
  29. package/esm/isMobile.js +5 -20
  30. package/esm/isPassport.js +5 -22
  31. package/esm/isPassword.js +7 -48
  32. package/esm/isPostcode.js +5 -20
  33. package/esm/isPromiseLike.js +3 -18
  34. package/esm/isQQ.js +5 -20
  35. package/esm/isSocialCreditCode.js +28 -83
  36. package/esm/isSwiftCode.js +6 -25
  37. package/esm/isTWCard.js +11 -37
  38. package/esm/isTelephone.js +6 -27
  39. package/esm/isUrl.js +5 -44
  40. package/esm/isVehicle.js +5 -28
  41. package/esm/isWX.js +5 -20
  42. package/esm/listToTree.js +51 -120
  43. package/esm/minus.js +21 -39
  44. package/esm/normalizeString.js +8 -29
  45. package/esm/numberToChinese.js +96 -215
  46. package/esm/padZero.js +14 -36
  47. package/esm/parseIdCard.js +64 -129
  48. package/esm/plus.js +21 -39
  49. package/esm/randomString.js +13 -45
  50. package/esm/replaceChar.js +27 -77
  51. package/esm/round.js +14 -31
  52. package/esm/safeDate.js +12 -55
  53. package/esm/setDataURLPrefix.js +6 -29
  54. package/esm/strlen.js +14 -30
  55. package/esm/times.js +24 -42
  56. package/esm/transformFieldNames.js +37 -93
  57. package/esm/treeToList.js +25 -84
  58. package/esm/utils/config.js +4 -14
  59. package/esm/utils/constants.js +4 -4
  60. package/esm/utils/convertToString.js +4 -9
  61. package/esm/utils/devWarn.js +11 -11
  62. package/esm/utils/math.util.js +95 -181
  63. package/esm/utils/type/isBlob.js +4 -24
  64. package/esm/utils/type/isNaN.js +4 -19
  65. package/esm/utils/type/isNil.js +5 -13
  66. package/esm/utils/type/isNull.js +3 -18
  67. package/esm/utils/type/isNumber.js +4 -28
  68. package/esm/utils/type/isObject.js +4 -23
  69. package/esm/utils/type/isString.js +4 -19
  70. package/esm/utils/type/isSymbol.js +4 -19
  71. package/esm/utils/type/isType.js +3 -12
  72. package/esm/utils/type/isUndefined.js +3 -21
  73. package/esm/validatePassword.js +86 -237
  74. package/esm/waitTime.js +7 -26
  75. package/lib/ajax.js +51 -152
  76. package/lib/blobToDataURL.js +5 -40
  77. package/lib/bytesToSize.js +13 -43
  78. package/lib/calculateCursorPosition.js +32 -58
  79. package/lib/dataURLToBlob.js +15 -34
  80. package/lib/divide.js +26 -60
  81. package/lib/download.js +85 -169
  82. package/lib/fileReader.js +19 -70
  83. package/lib/filterTree.js +27 -66
  84. package/lib/findTreeNode.js +40 -77
  85. package/lib/findTreeNodes.js +36 -76
  86. package/lib/findTreeSelect.js +40 -82
  87. package/lib/formatBankCard.js +15 -50
  88. package/lib/formatMobile.js +19 -50
  89. package/lib/formatMoney.js +60 -150
  90. package/lib/index.js +117 -395
  91. package/lib/isBankCard.js +24 -64
  92. package/lib/isBusinessLicense.js +34 -85
  93. package/lib/isChinese.js +24 -73
  94. package/lib/isEmail.js +7 -27
  95. package/lib/isHMCard.js +7 -35
  96. package/lib/isIPv4.js +7 -29
  97. package/lib/isIPv6.js +7 -43
  98. package/lib/isIdCard.js +29 -73
  99. package/lib/isMobile.js +7 -27
  100. package/lib/isPassport.js +7 -29
  101. package/lib/isPassword.js +9 -55
  102. package/lib/isPostcode.js +7 -27
  103. package/lib/isPromiseLike.js +4 -24
  104. package/lib/isQQ.js +7 -27
  105. package/lib/isSocialCreditCode.js +30 -90
  106. package/lib/isSwiftCode.js +7 -32
  107. package/lib/isTWCard.js +13 -44
  108. package/lib/isTelephone.js +7 -33
  109. package/lib/isUrl.js +6 -49
  110. package/lib/isVehicle.js +7 -35
  111. package/lib/isWX.js +7 -27
  112. package/lib/listToTree.js +53 -131
  113. package/lib/minus.js +23 -51
  114. package/lib/normalizeString.js +10 -36
  115. package/lib/numberToChinese.js +98 -222
  116. package/lib/padZero.js +16 -43
  117. package/lib/parseIdCard.js +65 -138
  118. package/lib/plus.js +23 -51
  119. package/lib/randomString.js +14 -51
  120. package/lib/replaceChar.js +28 -83
  121. package/lib/round.js +15 -37
  122. package/lib/safeDate.js +13 -63
  123. package/lib/setDataURLPrefix.js +7 -35
  124. package/lib/strlen.js +16 -37
  125. package/lib/times.js +26 -53
  126. package/lib/transformFieldNames.js +38 -101
  127. package/lib/treeToList.js +27 -94
  128. package/lib/utils/config.js +6 -23
  129. package/lib/utils/constants.js +3 -11
  130. package/lib/utils/convertToString.js +6 -16
  131. package/lib/utils/devWarn.js +13 -17
  132. package/lib/utils/math.util.js +95 -185
  133. package/lib/utils/type/isBlob.js +6 -31
  134. package/lib/utils/type/isNaN.js +6 -26
  135. package/lib/utils/type/isNil.js +7 -20
  136. package/lib/utils/type/isNull.js +4 -24
  137. package/lib/utils/type/isNumber.js +6 -35
  138. package/lib/utils/type/isObject.js +5 -29
  139. package/lib/utils/type/isString.js +6 -26
  140. package/lib/utils/type/isSymbol.js +6 -26
  141. package/lib/utils/type/isType.js +4 -18
  142. package/lib/utils/type/isUndefined.js +4 -27
  143. package/lib/validatePassword.js +87 -244
  144. package/lib/waitTime.js +8 -32
  145. package/package.json +21 -25
  146. package/types/ajax.d.ts +38 -95
  147. package/types/blobToDataURL.d.ts +2 -2
  148. package/types/bytesToSize.d.ts +7 -6
  149. package/types/calculateCursorPosition.d.ts +10 -9
  150. package/types/dataURLToBlob.d.ts +5 -5
  151. package/types/divide.d.ts +2 -2
  152. package/types/download.d.ts +22 -38
  153. package/types/fileReader.d.ts +35 -2
  154. package/types/filterTree.d.ts +6 -7
  155. package/types/findTreeNode.d.ts +5 -7
  156. package/types/findTreeNodes.d.ts +5 -7
  157. package/types/findTreeSelect.d.ts +5 -7
  158. package/types/formatBankCard.d.ts +8 -5
  159. package/types/formatMobile.d.ts +7 -4
  160. package/types/formatMoney.d.ts +8 -7
  161. package/types/index.d.ts +125 -55
  162. package/types/isBankCard.d.ts +9 -8
  163. package/types/isBusinessLicense.d.ts +8 -5
  164. package/types/isChinese.d.ts +9 -8
  165. package/types/isEmail.d.ts +1 -1
  166. package/types/isHMCard.d.ts +2 -2
  167. package/types/isIPv4.d.ts +1 -1
  168. package/types/isIPv6.d.ts +1 -1
  169. package/types/isIdCard.d.ts +8 -7
  170. package/types/isMobile.d.ts +1 -1
  171. package/types/isPassport.d.ts +2 -2
  172. package/types/isPassword.d.ts +4 -7
  173. package/types/isPostcode.d.ts +1 -1
  174. package/types/isPromiseLike.d.ts +1 -1
  175. package/types/isQQ.d.ts +1 -1
  176. package/types/isSocialCreditCode.d.ts +8 -5
  177. package/types/isSwiftCode.d.ts +2 -2
  178. package/types/isTWCard.d.ts +6 -5
  179. package/types/isTelephone.d.ts +1 -1
  180. package/types/isUrl.d.ts +2 -2
  181. package/types/isVehicle.d.ts +2 -2
  182. package/types/isWX.d.ts +1 -1
  183. package/types/listToTree.d.ts +12 -12
  184. package/types/minus.d.ts +3 -2
  185. package/types/normalizeString.d.ts +2 -2
  186. package/types/numberToChinese.d.ts +13 -12
  187. package/types/padZero.d.ts +2 -2
  188. package/types/parseIdCard.d.ts +17 -56
  189. package/types/plus.d.ts +3 -2
  190. package/types/randomString.d.ts +2 -2
  191. package/types/replaceChar.d.ts +15 -11
  192. package/types/round.d.ts +2 -2
  193. package/types/safeDate.d.ts +24 -2
  194. package/types/setDataURLPrefix.d.ts +5 -5
  195. package/types/strlen.d.ts +1 -1
  196. package/types/times.d.ts +3 -2
  197. package/types/transformFieldNames.d.ts +12 -10
  198. package/types/treeToList.d.ts +1 -1
  199. package/types/utils/config.d.ts +6 -5
  200. package/types/utils/constants.d.ts +2 -2
  201. package/types/utils/convertToString.d.ts +1 -1
  202. package/types/utils/devWarn.d.ts +1 -1
  203. package/types/utils/math.util.d.ts +15 -9
  204. package/types/utils/type/index.d.ts +7 -0
  205. package/types/utils/type/isArguments.d.ts +1 -1
  206. package/types/utils/type/isArray.d.ts +1 -1
  207. package/types/utils/type/isArrayBuffer.d.ts +1 -1
  208. package/types/utils/type/isBlob.d.ts +1 -1
  209. package/types/utils/type/isBoolean.d.ts +1 -1
  210. package/types/utils/type/isDate.d.ts +1 -1
  211. package/types/utils/type/isError.d.ts +1 -1
  212. package/types/utils/type/isFunction.d.ts +1 -1
  213. package/types/utils/type/isMap.d.ts +1 -1
  214. package/types/utils/type/isNaN.d.ts +1 -1
  215. package/types/utils/type/isNil.d.ts +1 -1
  216. package/types/utils/type/isNull.d.ts +1 -1
  217. package/types/utils/type/isNumber.d.ts +1 -1
  218. package/types/utils/type/isObject.d.ts +1 -1
  219. package/types/utils/type/isRegExp.d.ts +1 -1
  220. package/types/utils/type/isSet.d.ts +1 -1
  221. package/types/utils/type/isString.d.ts +1 -1
  222. package/types/utils/type/isSymbol.d.ts +1 -1
  223. package/types/utils/type/isType.d.ts +1 -1
  224. package/types/utils/type/isUndefined.d.ts +1 -1
  225. package/types/utils/type/isWeakMap.d.ts +1 -1
  226. package/types/utils/type/isWeakSet.d.ts +1 -1
  227. package/types/validatePassword.d.ts +17 -48
  228. package/types/waitTime.d.ts +2 -2
  229. package/esm/interface.doc.js +0 -125
  230. package/esm/interface.type.js +0 -17
  231. package/esm/utils/type/index.js +0 -29
  232. package/esm/utils/type/isArguments.js +0 -22
  233. package/esm/utils/type/isArray.js +0 -22
  234. package/esm/utils/type/isArrayBuffer.js +0 -25
  235. package/esm/utils/type/isBoolean.js +0 -22
  236. package/esm/utils/type/isDate.js +0 -22
  237. package/esm/utils/type/isError.js +0 -22
  238. package/esm/utils/type/isFunction.js +0 -22
  239. package/esm/utils/type/isMap.js +0 -22
  240. package/esm/utils/type/isRegExp.js +0 -22
  241. package/esm/utils/type/isSet.js +0 -22
  242. package/esm/utils/type/isWeakMap.js +0 -22
  243. package/esm/utils/type/isWeakSet.js +0 -22
  244. package/lib/interface.doc.js +0 -127
  245. package/lib/interface.type.js +0 -5
  246. package/lib/utils/type/index.js +0 -146
  247. package/lib/utils/type/isArguments.js +0 -29
  248. package/lib/utils/type/isArray.js +0 -29
  249. package/lib/utils/type/isArrayBuffer.js +0 -32
  250. package/lib/utils/type/isBoolean.js +0 -29
  251. package/lib/utils/type/isDate.js +0 -29
  252. package/lib/utils/type/isError.js +0 -29
  253. package/lib/utils/type/isFunction.js +0 -29
  254. package/lib/utils/type/isMap.js +0 -29
  255. package/lib/utils/type/isRegExp.js +0 -29
  256. package/lib/utils/type/isSet.js +0 -29
  257. package/lib/utils/type/isWeakMap.js +0 -29
  258. package/lib/utils/type/isWeakSet.js +0 -29
  259. package/types/interface.type.d.ts +0 -2
@@ -1,13 +1,16 @@
1
- export default isChinese;
1
+ type Options = {
2
+ loose?: boolean;
3
+ useExtend?: boolean;
4
+ };
2
5
  /**
3
6
  * 检测值是否为中文
4
7
  *
5
8
  * @static
6
9
  * @alias module:Validator.isChinese
7
10
  * @since 1.1.0
8
- * @see {@link http://www.unicode.org/reports/tr38/#BlockListing|4.4 Listing of Characters Covered by the Unihan Database}
9
- * @see {@link https://zh.wikipedia.org/wiki/Unicode字符平面映射|Unicode字符平面映射}
10
- * @see {@link https://zh.wikipedia.org/wiki/Unicode區段|Unicode区段}
11
+ * @see {@link http://www.unicode.org/reports/tr38/#BlockListing | 4.4 Listing of Characters Covered by the Unihan Database}
12
+ * @see {@link https://zh.wikipedia.org/wiki/Unicode字符平面映射 | Unicode字符平面映射}
13
+ * @see {@link https://zh.wikipedia.org/wiki/Unicode區段 | Unicode区段}
11
14
  * @param {*} value 要检测的值
12
15
  * @param {Object} [options] 配置项
13
16
  * @param {boolean} [options.loose=false] 宽松模式。如果为true,只要包含中文即为true
@@ -30,7 +33,5 @@ export default isChinese;
30
33
  * isChinese('𠮷aa', { useExtend: true, loose: true }); // true
31
34
  *
32
35
  */
33
- declare function isChinese(value: any, options?: {
34
- loose?: boolean | undefined;
35
- useExtend?: boolean | undefined;
36
- } | undefined): boolean;
36
+ declare function isChinese(value: any, options?: Options): boolean;
37
+ export default isChinese;
@@ -1,4 +1,3 @@
1
- export default isEmail;
2
1
  /**
3
2
  * 检测值是否为Email
4
3
  *
@@ -14,3 +13,4 @@ export default isEmail;
14
13
  *
15
14
  */
16
15
  declare function isEmail(value: any): boolean;
16
+ export default isEmail;
@@ -1,11 +1,10 @@
1
- export default isHMCard;
2
1
  /**
3
2
  * 检测值是否为港澳居民来往内地通行证,俗称回乡证或回乡卡。
4
3
  *
5
4
  * @static
6
5
  * @alias module:Validator.isHMCard
7
6
  * @since 4.0.0
8
- * @see {@link https://zh.wikipedia.org/wiki/港澳居民来往内地通行证|港澳居民来往内地通行证}
7
+ * @see {@link https://zh.wikipedia.org/wiki/港澳居民来往内地通行证 | 港澳居民来往内地通行证}
9
8
  * @param {*} value 要检测的值
10
9
  * @returns {boolean} 是否为港澳居民来往内地通行证
11
10
  * @example
@@ -22,3 +21,4 @@ export default isHMCard;
22
21
  * isHMCard('M32031177'); // true
23
22
  */
24
23
  declare function isHMCard(value: any): boolean;
24
+ export default isHMCard;
package/types/isIPv4.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default isIPv4;
2
1
  /**
3
2
  * 检测值是否为ipv4
4
3
  *
@@ -16,3 +15,4 @@ export default isIPv4;
16
15
  *
17
16
  */
18
17
  declare function isIPv4(value: any): boolean;
18
+ export default isIPv4;
package/types/isIPv6.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default isIPv6;
2
1
  /**
3
2
  * 检测值是否为ipv6
4
3
  *
@@ -30,3 +29,4 @@ export default isIPv6;
30
29
  *
31
30
  */
32
31
  declare function isIPv6(value: any): boolean;
32
+ export default isIPv6;
@@ -1,12 +1,15 @@
1
- export default isIdCard;
1
+ type Options = {
2
+ loose?: boolean;
3
+ checkCode?: boolean;
4
+ };
2
5
  /**
3
6
  * 检测值是否为18位身份证号码。<br/>宽松模式下,支持15位身份证号码
4
7
  *
5
8
  * @static
6
9
  * @alias module:Validator.isIdCard
7
10
  * @since 1.1.0
8
- * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码|中华人民共和国公民身份号码}
9
- * @see {@link https://baike.baidu.com/item/居民身份证号码|居民身份证号码}
11
+ * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码 | 中华人民共和国公民身份号码}
12
+ * @see {@link https://baike.baidu.com/item/居民身份证号码 | 居民身份证号码}
10
13
  * @param {*} value 要检测的值
11
14
  * @param {Object} [options] 配置项
12
15
  * @param {boolean} [options.loose=false] 宽松模式,支持15位身份证号码
@@ -27,7 +30,5 @@ export default isIdCard;
27
30
  * isIdCard('320311770706001', { loose: true }); // true
28
31
  *
29
32
  */
30
- declare function isIdCard(value: any, options?: {
31
- loose?: boolean | undefined;
32
- checkCode?: boolean | undefined;
33
- } | undefined): boolean;
33
+ declare function isIdCard(value: any, options?: Options): boolean;
34
+ export default isIdCard;
@@ -1,4 +1,3 @@
1
- export default isMobile;
2
1
  /**
3
2
  * 检测值是否为手机号码
4
3
  *
@@ -14,3 +13,4 @@ export default isMobile;
14
13
  *
15
14
  */
16
15
  declare function isMobile(value: any): boolean;
16
+ export default isMobile;
@@ -1,4 +1,3 @@
1
- export default isPassport;
2
1
  /**
3
2
  * 检测值是否为护照号
4
3
  * 支持普通护照(E*)、外交护照(DE)、公务护照(SE)、公务普通护照(PE)、香港特区护照(K/KJ/H*)、澳门特区护照(MA/MB/M*),注意不区分大小写
@@ -6,7 +5,7 @@ export default isPassport;
6
5
  * @static
7
6
  * @alias module:Validator.isPassport
8
7
  * @since 1.1.0
9
- * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国护照#个人资料页|中华人民共和国护照#个人资料页}
8
+ * @see {@link https://zh.wikipedia.org/wiki/中华人民共和国护照#个人资料页 | 中华人民共和国护照#个人资料页}
10
9
  * @param {*} value 要检测的值
11
10
  * @returns {boolean} 值是否为护照号
12
11
  * @example
@@ -16,3 +15,4 @@ export default isPassport;
16
15
  *
17
16
  */
18
17
  declare function isPassport(value: any): boolean;
18
+ export default isPassport;
@@ -1,4 +1,4 @@
1
- export default isPassword;
1
+ import validatePassword from './validatePassword';
2
2
  /**
3
3
  * 检测值是否符合密码强度
4
4
  * <p><strong>注意:该校验只校验是否存在不同字符(大小写字母、数字、特殊符号),不判断长度。</strong></p>
@@ -8,7 +8,7 @@ export default isPassword;
8
8
  * @alias module:Validator.isPassword
9
9
  * @requires module:Validator.validatePassword
10
10
  * @since 1.1.0
11
- * @see {@link https://baike.baidu.com/item/ASCII#3|ASCII}
11
+ * @see {@link https://baike.baidu.com/item/ASCII#3 | ASCII}
12
12
  * @param {*} value 要检测的值
13
13
  * @param {Object} [options] 配置项
14
14
  * @param {number} [options.level=2] 密码强度 1-包含一种字符 2-包含两种字符 3-包含三种字符。(大写字母、小写字母、数字、特殊字符)
@@ -32,8 +32,5 @@ export default isPassword;
32
32
  * isPassword(' _Aa12345678', {level: 3, ignoreCase: true}); // false
33
33
  *
34
34
  */
35
- declare function isPassword(value: any, options?: {
36
- level?: number | undefined;
37
- ignoreCase?: boolean | undefined;
38
- special?: string | undefined;
39
- } | undefined): boolean;
35
+ declare function isPassword(value: any, options?: Parameters<typeof validatePassword>[1]): boolean;
36
+ export default isPassword;
@@ -1,4 +1,3 @@
1
- export default isPostcode;
2
1
  /**
3
2
  * 检测值是否为邮政编码,6位数字
4
3
  *
@@ -14,3 +13,4 @@ export default isPostcode;
14
13
  *
15
14
  */
16
15
  declare function isPostcode(value: any): boolean;
16
+ export default isPostcode;
@@ -1,4 +1,3 @@
1
- export default isPromiseLike;
2
1
  /**
3
2
  * 检测值是否类似Promise对象
4
3
  *
@@ -15,3 +14,4 @@ export default isPromiseLike;
15
14
  *
16
15
  */
17
16
  declare function isPromiseLike(obj: any): boolean;
17
+ export default isPromiseLike;
package/types/isQQ.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default isQQ;
2
1
  /**
3
2
  * 检测值是否为QQ号,非0开头,5至11位数字
4
3
  *
@@ -14,3 +13,4 @@ export default isQQ;
14
13
  *
15
14
  */
16
15
  declare function isQQ(value: any): boolean;
16
+ export default isQQ;
@@ -1,11 +1,15 @@
1
- export default isSocialCreditCode;
1
+ type Options = {
2
+ /** @deprecated */
3
+ loose?: boolean;
4
+ checkCode?: boolean;
5
+ };
2
6
  /**
3
7
  * 检测值是否为统一社会信用代码,也叫三证合一组织代码。由18位数字和大写字母组成,不使用I、O、Z、S、V。
4
8
  *
5
9
  * @static
6
10
  * @alias module:Validator.isSocialCreditCode
7
11
  * @since 1.1.0
8
- * @see {@link https://zh.wikisource.org/zh-hans/GB_32100-2015_法人和其他组织统一社会信用代码编码规则|GB 32100-2015 法人和其他组织统一社会信用代码编码规则}
12
+ * @see {@link https://zh.wikisource.org/zh-hans/GB_32100-2015_法人和其他组织统一社会信用代码编码规则 | GB 32100-2015 法人和其他组织统一社会信用代码编码规则}
9
13
  * @param {*} value 要检测的值
10
14
  * @param {Object} [options] 配置项
11
15
  * @param {boolean} [options.checkCode=true] 是否校验最后一位校验码,如果为false,不校验校验位。
@@ -21,6 +25,5 @@ export default isSocialCreditCode;
21
25
  * isSocialCreditCode('91350100M000100Y', { checkCode: false }); // false
22
26
  *
23
27
  */
24
- declare function isSocialCreditCode(value: any, options?: {
25
- checkCode?: boolean | undefined;
26
- } | undefined): boolean;
28
+ declare function isSocialCreditCode(value: any, options?: Options): boolean;
29
+ export default isSocialCreditCode;
@@ -1,11 +1,10 @@
1
- export default isSwiftCode;
2
1
  /**
3
2
  * 检测值是否为 Swift Code。8位或11位,前6位为大写字母,7-8位为大写字母或数字,9-11位为可选的大写字母或数字。
4
3
  *
5
4
  * @static
6
5
  * @alias module:Validator.isSwiftCode
7
6
  * @since 4.9.0
8
- * @see {@link https://zh.wikipedia.org/wiki/ISO_9362|ISO 9362}
7
+ * @see {@link https://zh.wikipedia.org/wiki/ISO_9362 | ISO 9362}
9
8
  * @param {*} value 要检测的值
10
9
  * @returns {boolean} 值是否为 Swift Code
11
10
  * @example
@@ -20,3 +19,4 @@ export default isSwiftCode;
20
19
  *
21
20
  */
22
21
  declare function isSwiftCode(value: any): boolean;
22
+ export default isSwiftCode;
@@ -1,11 +1,13 @@
1
- export default isTWCard;
1
+ type Options = {
2
+ loose?: boolean;
3
+ };
2
4
  /**
3
5
  * 检测值是否为台湾居民来往大陆通行证,俗称台胞证。
4
6
  *
5
7
  * @static
6
8
  * @alias module:Validator.isTWCard
7
9
  * @since 4.0.0
8
- * @see {@link https://zh.wikipedia.org/wiki/台湾居民来往大陆通行证|台湾居民来往大陆通行证}
10
+ * @see {@link https://zh.wikipedia.org/wiki/台湾居民来往大陆通行证 | 台湾居民来往大陆通行证}
9
11
  * @param {*} value 要检测的值
10
12
  * @param {Object} [options] 配置项
11
13
  * @param {boolean} [options.loose=false] 宽松模式。如果为true,表示支持一次性短期通行证
@@ -21,6 +23,5 @@ export default isTWCard;
21
23
  * // 宽松模式,支持一次性短期通行证
22
24
  * isTWCard('F290299977', { loose: true }); // true
23
25
  */
24
- declare function isTWCard(value: any, options?: {
25
- loose?: boolean | undefined;
26
- } | undefined): boolean;
26
+ declare function isTWCard(value: any, options?: Options): boolean;
27
+ export default isTWCard;
@@ -1,4 +1,3 @@
1
- export default isTelephone;
2
1
  /**
3
2
  * 检测值是否为固定电话
4
3
  *
@@ -20,3 +19,4 @@ export default isTelephone;
20
19
  *
21
20
  */
22
21
  declare function isTelephone(value: any): boolean;
22
+ export default isTelephone;
package/types/isUrl.d.ts CHANGED
@@ -1,11 +1,10 @@
1
- export default isUrl;
2
1
  /**
3
2
  * 检测值是否为url
4
3
  *
5
4
  * @static
6
5
  * @alias module:Validator.isUrl
7
6
  * @since 3.4.0
8
- * @see {@link https://zh.wikipedia.org/wiki/统一资源定位符|统一资源定位符}
7
+ * @see {@link https://zh.wikipedia.org/wiki/统一资源定位符 | 统一资源定位符}
9
8
  * @param {*} value 要检测的值
10
9
  * @returns {boolean} 值是否为url
11
10
  * @example
@@ -31,3 +30,4 @@ export default isUrl;
31
30
  *
32
31
  */
33
32
  declare function isUrl(value: any): boolean;
33
+ export default isUrl;
@@ -1,11 +1,10 @@
1
- export default isVehicle;
2
1
  /**
3
2
  * 检测值是否为车牌号,支持新能源和非新能源车牌
4
3
  *
5
4
  * @static
6
5
  * @alias module:Validator.isVehicle
7
6
  * @since 1.1.0
8
- * @see {@link https://baike.baidu.com/item/车牌号|车牌号}
7
+ * @see {@link https://baike.baidu.com/item/车牌号 | 车牌号}
9
8
  * @param {*} value 要检测的值
10
9
  * @returns {boolean} 值是否为车牌号
11
10
  * @example
@@ -22,3 +21,4 @@ export default isVehicle;
22
21
  *
23
22
  */
24
23
  declare function isVehicle(value: any): boolean;
24
+ export default isVehicle;
package/types/isWX.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default isWX;
2
1
  /**
3
2
  * 检测值是否为微信号
4
3
  *
@@ -14,3 +13,4 @@ export default isWX;
14
13
  *
15
14
  */
16
15
  declare function isWX(value: any): boolean;
16
+ export default isWX;
@@ -1,20 +1,25 @@
1
- export default listToTree;
1
+ type NodeAssign = 'spread' | 'self';
2
+ type Options = {
3
+ keyField?: string;
4
+ parentField?: string;
5
+ childrenField?: string;
6
+ emptyChildrenValue?: 'none' | 'null' | 'array';
7
+ nodeAssign?: NodeAssign;
8
+ };
2
9
  /**
3
10
  * 列表数据转树结构
4
11
  *
5
12
  * @static
6
13
  * @alias module:Tree.listToTree
7
14
  * @since 4.14.0
8
- * @template {Record<string,any>} [T=Record<string,any>]
9
- * @template {*} [R=T&Record<string,any>]
10
- * @param {T[]} list 列表数据
15
+ * @param {object[]} list 列表数据
11
16
  * @param {object} [options] 配置项
12
17
  * @param {string} [options.keyField='id'] 当前数据的键值字段名称
13
18
  * @param {string} [options.parentField='pid'] 当前数据的父级字段名称
14
19
  * @param {string} [options.childrenField='children'] 子级字段名称
15
20
  * @param {'none'|'null'|'array'} [options.emptyChildrenValue='none'] 子级为空时的值,none表示删除该子级,null表示为null,array表示为[]。
16
21
  * @param {'spread'|'self'} [options.nodeAssign='spread'] 节点赋值方式。spread表示使用展开运算符创建新值,self表示使用自身对象。
17
- * @returns {R[]} 树结构
22
+ * @returns {object[]} 树结构
18
23
  * @example
19
24
  *
20
25
  * const menus = [
@@ -34,10 +39,5 @@ export default listToTree;
34
39
  * // [{"id":"1","name":"首页","code":"trade","pid":null},{"id":"2","name":"交易管理","code":"trade","pid":null,"childs":[{"id":"3","name":"交易查询","code":"trade-1","pid":"2","childs":[{"id":"4","name":"交易查询-查询操作","code":"trade-1-1","pid":"3"}]}]},{"id":"5","name":"权限管理","code":"authorization","pid":null,"childs":[{"id":"6","name":"角色管理","code":"authorization-1","pid":"5"},{"id":"7","name":"用户管理","code":"authorization-2","pid":"5"}]}]
35
40
  *
36
41
  */
37
- declare function listToTree<T extends Record<string, any> = Record<string, any>, R extends unknown = T & Record<string, any>>(list: T[], options?: {
38
- keyField?: string | undefined;
39
- parentField?: string | undefined;
40
- childrenField?: string | undefined;
41
- emptyChildrenValue?: "none" | "null" | "array" | undefined;
42
- nodeAssign?: "spread" | "self" | undefined;
43
- } | undefined): R[];
42
+ declare function listToTree<T extends Record<string, any> = Record<string, any>, R extends unknown = T & Record<string, any>>(list: T[], options?: Options): R[];
43
+ export default listToTree;
package/types/minus.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default minus;
2
1
  /**
3
2
  * 精确减法,支持多个数相减,减数默认为 0 。
4
3
  *
@@ -9,9 +8,11 @@ export default minus;
9
8
  * @returns {number} 差
10
9
  * @example
11
10
  *
11
+ * minus(1); // 1
12
12
  * minus(1, 0.9); // 0.1
13
13
  * minus(1, 0.9, 0.02); // 0.08
14
14
  * minus(1, 0.9, 0.02, 0.08); // 0
15
15
  *
16
16
  */
17
- declare function minus(...nums: (number | string)[]): number;
17
+ declare function minus(...nums: (string | number)[]): number;
18
+ export default minus;
@@ -1,11 +1,10 @@
1
- export default normalizeString;
2
1
  /**
3
2
  * 规整化字符串。如果值为 undefined 或 null 将转为空字符串,如果值不是字符串类型将转为字符串。
4
3
  *
5
4
  * @static
6
5
  * @alias module:Processor.normalizeString
7
6
  * @since 4.3.0
8
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#string_instances|String}
7
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String#string_instances | String}
9
8
  * @param {*} value 待处理的值
10
9
  * @returns {string} 规整化的值
11
10
  * @example
@@ -22,3 +21,4 @@ export default normalizeString;
22
21
  *
23
22
  */
24
23
  declare function normalizeString(value: any): string;
24
+ export default normalizeString;
@@ -1,4 +1,14 @@
1
- export default numberToChinese;
1
+ type Options = {
2
+ big5?: boolean;
3
+ unit?: boolean;
4
+ decimal?: string;
5
+ zero?: string;
6
+ negative?: string;
7
+ unitConfig?: {
8
+ w?: string;
9
+ y?: string;
10
+ };
11
+ };
2
12
  /**
3
13
  * 数字转中文数字<br/><br/>
4
14
  *
@@ -37,14 +47,5 @@ export default numberToChinese;
37
47
  * numberToChinese(1990, {unit: false, zero:'〇'}); // 一九九〇
38
48
  *
39
49
  */
40
- declare function numberToChinese(num: number, options?: {
41
- big5?: boolean | undefined;
42
- unit?: boolean | undefined;
43
- decimal?: string | undefined;
44
- zero?: string | undefined;
45
- negative?: string | undefined;
46
- unitConfig?: {
47
- w?: string | undefined;
48
- y?: string | undefined;
49
- } | undefined;
50
- } | undefined): string;
50
+ declare function numberToChinese(num: number, options?: Options): string;
51
+ export default numberToChinese;
@@ -1,4 +1,3 @@
1
- export default padZero;
2
1
  /**
3
2
  * 前置补零
4
3
  *
@@ -22,4 +21,5 @@ export default padZero;
22
21
  * padZero('688', 5); // 00688
23
22
  *
24
23
  */
25
- declare function padZero(value: string | number, size?: number | undefined): string;
24
+ declare function padZero(value: string | number, size?: number): string;
25
+ export default padZero;
@@ -1,58 +1,3 @@
1
- export default parseIdCard;
2
- /**
3
- * - 解析身份证原数据
4
- */
5
- export type IdCardOrigin = {
6
- /**
7
- * - 省份编码
8
- */
9
- province: string;
10
- /**
11
- * - 城市编码
12
- */
13
- city: string;
14
- /**
15
- * - 地区编码
16
- */
17
- area: string;
18
- /**
19
- * - 出生年
20
- */
21
- year: string;
22
- /**
23
- * - 出生月
24
- */
25
- month: string;
26
- /**
27
- * - 出生日
28
- */
29
- day: string;
30
- /**
31
- * - 性别 能整除2为女,否则为男
32
- */
33
- gender: string;
34
- };
35
- /**
36
- * - 身份证信息
37
- */
38
- export type IdCardInfo = {
39
- /**
40
- * - 省份
41
- */
42
- province: string;
43
- /**
44
- * - 生日
45
- */
46
- birthday: string;
47
- /**
48
- * - 性别
49
- */
50
- gender: string;
51
- /**
52
- * - 解析身份证原数据
53
- */
54
- origin: IdCardOrigin;
55
- };
56
1
  /**
57
2
  * @typedef {Object} IdCardOrigin - 解析身份证原数据
58
3
  * @property {string} province - 省份编码
@@ -70,13 +15,28 @@ export type IdCardInfo = {
70
15
  * @property {string} gender - 性别
71
16
  * @property {IdCardOrigin} origin - 解析身份证原数据
72
17
  */
18
+ type IdCardOrigin = {
19
+ province: string;
20
+ city: string;
21
+ area: string;
22
+ year: string;
23
+ month: string;
24
+ day: string;
25
+ gender: string;
26
+ };
27
+ type IdCardInfo = {
28
+ province: string;
29
+ birthday: string;
30
+ gender: string;
31
+ origin: IdCardOrigin;
32
+ };
73
33
  /**
74
34
  * 解析身份证号码,支持15、18位身份证号码
75
35
  *
76
36
  * @static
77
37
  * @alias module:Processor.parseIdCard
78
38
  * @since 4.0.0
79
- * @see {@link https://baike.baidu.com/item/居民身份证号码|居民身份证号码}
39
+ * @see {@link https://baike.baidu.com/item/居民身份证号码 | 居民身份证号码}
80
40
  * @param {string} id 身份证号码,支持15位
81
41
  * @returns {IdCardInfo | null} 省份、生日、性别,省/市/区/年/月/日/性别编码。如果解析失败将返回 null 。
82
42
  * @example
@@ -105,3 +65,4 @@ export type IdCardInfo = {
105
65
  *
106
66
  */
107
67
  declare function parseIdCard(id: string): IdCardInfo | null;
68
+ export default parseIdCard;
package/types/plus.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default plus;
2
1
  /**
3
2
  * 精确加法,支持多个数相加,加数默认为 0 。
4
3
  *
@@ -9,9 +8,11 @@ export default plus;
9
8
  * @returns {number} 总和
10
9
  * @example
11
10
  *
11
+ * plus(0.1); // 0.1
12
12
  * plus(0.1, 0.2); // 0.3
13
13
  * plus(0.1, 0.2, 0.3); // 0.6
14
14
  * plus(0.1, 0.2, 0.3, 0.4); // 1
15
15
  *
16
16
  */
17
- declare function plus(...nums: (number | string)[]): number;
17
+ declare function plus(...nums: (string | number)[]): number;
18
+ export default plus;
@@ -1,4 +1,3 @@
1
- export default randomString;
2
1
  /**
3
2
  * 生成随机字符串
4
3
  *
@@ -18,4 +17,5 @@ export default randomString;
18
17
  * randomString(8, 'abcefg'); // bcgcfabg
19
18
  *
20
19
  */
21
- declare function randomString(len?: number | undefined, optionalChars?: string | undefined): string;
20
+ declare function randomString(len?: number, optionalChars?: string): string;
21
+ export default randomString;
@@ -1,4 +1,10 @@
1
- export default replaceChar;
1
+ type Options = {
2
+ start?: number;
3
+ end?: number;
4
+ char?: string;
5
+ repeat?: number;
6
+ exclude?: string;
7
+ };
2
8
  /**
3
9
  * 替换字符,应用场景如:脱敏
4
10
  *
@@ -21,17 +27,20 @@ export default replaceChar;
21
27
  * // 身份证 前6后4
22
28
  * replaceChar('130701199310302288', { start: 6, end: -4 }); // 130701********2288
23
29
  *
24
- * // 邮箱 @前两位
25
- * const email = '12345@qq.com'
30
+ * // 邮箱@前两位
31
+ * const email = '12345@qq.com';
26
32
  * const emailAtIndex = email.indexOf('@');
27
- * replaceChar(email, { start: emailAtIndex - 2, end: emailAtIndex }); // 123**@qq.com
33
+ * replaceChar('email', { start: emailAtIndex - 2, end: emailAtIndex }); // 123**@qq.com
34
+ *
28
35
  * // 邮箱 前2和@后面内容,固定替换字符4位
29
36
  * replaceChar(email, {start: 2, end: email.indexOf('@'), repeat: 4}); // 12****@qq.com
30
37
  *
31
38
  * // 银行卡号 只展示后4位,固定替换字符4位
32
39
  * replaceChar('6228480402564890018', {start: 0, end: -4, repeat: 4}); // ****0018
40
+ *
33
41
  * // 银行卡号 前6后4
34
42
  * replaceChar('6228480402564890018', { start: 6, end: -4 }); // 622848*********0018
43
+ *
35
44
  * // 银行卡号 前4后3 忽略格式的空格
36
45
  * replaceChar('6228 4804 0256 4890 018', {start: 4, end: -4, exclude: ' '}); // 6228 **** **** **** 018
37
46
  *
@@ -41,10 +50,5 @@ export default replaceChar;
41
50
  * replaceChar('林某某某', {start: 1, end: Infinity, repeat: 2}); // 林**
42
51
  *
43
52
  */
44
- declare function replaceChar(str: string, options?: {
45
- start?: number | undefined;
46
- end?: number | undefined;
47
- char?: string | undefined;
48
- repeat?: number | undefined;
49
- exclude?: string | undefined;
50
- } | undefined): string;
53
+ declare function replaceChar(str: string, options?: Options): string;
54
+ export default replaceChar;
package/types/round.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default round;
2
1
  /**
3
2
  * 四舍五入,支持设置精度
4
3
  *
@@ -15,4 +14,5 @@ export default round;
15
14
  * round(4060, -2); // 4100
16
15
  *
17
16
  */
18
- declare function round(num: number | string, precision?: number | undefined): number;
17
+ declare function round(num: string | number, precision?: number): number;
18
+ export default round;