util-helpers 4.16.2 → 4.17.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.
Files changed (259) hide show
  1. package/dist/util-helpers.js +1542 -4040
  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,4 +1,26 @@
1
- export default safeDate;
1
+ /**
2
+ * 创建一个 Date 实例日期对象,同 <a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date#%E5%8F%82%E6%95%B0">new Date()</a> <br/><br/>
3
+ *
4
+ * 规避了苹果设备浏览器不支持部分格式(例如,YYYY-MM-DD HH-mm 或 YYYY.MM.DD)。<br/>
5
+ * 如果参数为 undefined 正常返回 Date 。
6
+ *
7
+ * @static
8
+ * @alias module:Processor.safeDate
9
+ * @since 4.4.0
10
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date | Date}
11
+ * @param {string|number|Date} [value] 日期时间字符串、毫秒数、日期对象
12
+ * @param {...number} [args] 月/日/时/分/秒/毫秒
13
+ * @returns {Date} Date 实例日期对象
14
+ * @example
15
+ *
16
+ * safeDate('2022-1-1'); // Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)
17
+ * safeDate('2022/1/1'); // Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)
18
+ * safeDate('2022.1.1'); // Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)
19
+ * safeDate('2022.1.1 11:11'); // Sat Jan 01 2022 11:11:00 GMT+0800 (中国标准时间)
20
+ * safeDate(99, 1); // Mon Feb 01 1999 00:00:00 GMT+0800 (中国标准时间)
21
+ * safeDate(1646711233171); // Tue Mar 08 2022 11:47:13 GMT+0800 (中国标准时间)
22
+ */
2
23
  declare function safeDate(): Date;
3
24
  declare function safeDate(value: number | string | Date): Date;
4
- declare function safeDate(year: number, monthIndex: number, date?: number | undefined, hours?: number | undefined, minutes?: number | undefined, seconds?: number | undefined, ms?: number | undefined): Date;
25
+ declare function safeDate(year: number, monthIndex: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date;
26
+ export default safeDate;
@@ -1,4 +1,3 @@
1
- export default setDataURLPrefix;
2
1
  /**
3
2
  * 设置 DataURL 前缀、MIME 类型、base64 标识。<br/>
4
3
  * 如果你需要获取DataURL 的 MIME 类型和数据本身,推荐使用 <a href="https://www.npmjs.com/package/data-urls">data-urls</a>。
@@ -6,10 +5,10 @@ export default setDataURLPrefix;
6
5
  * @static
7
6
  * @alias module:Processor.setDataURLPrefix
8
7
  * @since 4.1.0
9
- * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/Data_URIs|Data URLs}
10
- * @see {@link https://mimesniff.spec.whatwg.org/#understanding-mime-types|MIME types}
8
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URLs}
9
+ * @see {@link https://mimesniff.spec.whatwg.org/#understanding-mime-types | MIME types}
11
10
  * @param {string} data 数据本身
12
- * @param {string} [mimetype="image/png"] MIME 类型
11
+ * @param {string} [mimeType="image/png"] MIME 类型
13
12
  * @param {boolean} [base64=true] 添加 base64 标识
14
13
  * @returns {string} DataURL 格式的字符串
15
14
  * @example
@@ -23,4 +22,5 @@ export default setDataURLPrefix;
23
22
  * setDataURLPrefix(data, '', false); // data:,PGEgaWQ9ImEiPjxiIGlkPSJiIj5oZXkhPC9iPjwvYT4=
24
23
  *
25
24
  */
26
- declare function setDataURLPrefix(data: string, mimetype?: string | undefined, base64?: boolean | undefined): string;
25
+ declare function setDataURLPrefix(data: string, mimeType?: string, base64?: boolean): string;
26
+ export default setDataURLPrefix;
package/types/strlen.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default strlen;
2
1
  /**
3
2
  * 获取字符长度。中文汉字占2个字符,英文占1个字符,特殊如emoji占4个字符。
4
3
  *
@@ -18,3 +17,4 @@ export default strlen;
18
17
  *
19
18
  */
20
19
  declare function strlen(str: string): number;
20
+ export default strlen;
package/types/times.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export default times;
2
1
  /**
3
2
  * 精确乘法,支持多个数相乘,乘数默认为 1 。
4
3
  *
@@ -9,9 +8,11 @@ export default times;
9
8
  * @returns {number} 乘积
10
9
  * @example
11
10
  *
11
+ * times(3); // 3
12
12
  * times(3, 0.6); // 1.8
13
13
  * times(3, 0.6, 2); // 3.6
14
14
  * times(3, 0.6, 2, 10); // 36
15
15
  *
16
16
  */
17
- declare function times(...nums: (number | string)[]): number;
17
+ declare function times(...nums: (string | number)[]): number;
18
+ export default times;
@@ -1,18 +1,19 @@
1
- export default transformFieldNames;
1
+ type NodeAssign = 'spread' | 'self';
2
+ type ExchangeFieldNames<D extends any, F extends Record<string, keyof D>> = Omit<D, F[keyof F]> & {
3
+ [P in keyof F]: D[F[P]];
4
+ };
5
+ type TransformFieldNames<D extends any, F extends Record<string, any>, C extends string> = (C extends keyof D ? ExchangeFieldNames<Omit<D, C> & Record<C, TransformFieldNames<D, F, C>>, F> : ExchangeFieldNames<D, F>)[];
2
6
  /**
3
7
  * 转换字段名,返回一个转换字段后的值,不改变原值。
4
8
  *
5
9
  * @static
6
- * @alias module:Processor.transformFieldNames
10
+ * @alias module:Tree.transformFieldNames
7
11
  * @since 4.14.0
8
- * @template {*} D
9
- * @template {Record<string, keyof D>} F
10
- * @template {string} C
11
- * @param {D[]} data 对象数组。如果是树结构数据,需要指定第三个参数 childrenField
12
- * @param {F} fieldNames 字段名映射
13
- * @param {C} [childrenField] 子级数据字段名
12
+ * @param {object[]} data 对象数组。如果是树结构数据,需要指定第三个参数 childrenField
13
+ * @param {function} fieldNames 字段名映射
14
+ * @param {string} [childrenField] 子级数据字段名
14
15
  * @param {'spread'|'self'} [nodeAssign='spread'] 节点赋值方式。spread表示使用展开运算符创建新值,self表示使用自身对象。
15
- * @returns {import('./interface.type.js').TransformFieldNames<D, F, C>}
16
+ * @returns {object[]}
16
17
  * @example
17
18
  *
18
19
  * const options = [{code: '1', name: 'one'},{code:'2', name:'two'}];
@@ -32,4 +33,5 @@ export default transformFieldNames;
32
33
  * const newOptions4 = transformFieldNames(options3, {label: 'name', value: 'code', children: 'childs'}, 'childs');
33
34
  * // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one'}]}]
34
35
  */
35
- declare function transformFieldNames<D extends unknown, F extends Record<string, keyof D>, C extends string>(data: D[], fieldNames: F, childrenField?: C | undefined, nodeAssign?: "spread" | "self" | undefined): import("./interface.type.js").TransformFieldNames<D, F, C>;
36
+ declare function transformFieldNames<D extends any, F extends Record<string, keyof D>, C extends string>(data: D[], fieldNames: F, childrenField?: C, nodeAssign?: NodeAssign): TransformFieldNames<D, F, C>;
37
+ export default transformFieldNames;
@@ -1,4 +1,3 @@
1
- export default treeToList;
2
1
  /**
3
2
  * 树结构转列表数据
4
3
  *
@@ -18,3 +17,4 @@ export default treeToList;
18
17
  * // [{"id":"1","name":"首页","code":"trade","pid":null},{"id":"2","name":"交易管理","code":"trade","pid":null},{"id":"3","name":"交易查询","code":"trade-1","pid":"2"},{"id":"4","name":"交易查询-查询操作","code":"trade-1-1","pid":"3"},{"id":"5","name":"权限管理","code":"authorization","pid":null},{"id":"6","name":"角色管理","code":"authorization-1","pid":"5"},{"id":"7","name":"用户管理","code":"authorization-2","pid":"5"}]
19
18
  */
20
19
  declare function treeToList<T extends Record<string, any>, K extends keyof T, R extends Omit<T, K>>(tree: T[], childrenField: K): R[];
20
+ export default treeToList;
@@ -1,6 +1,6 @@
1
- export namespace config {
2
- const disableWarning: boolean;
3
- }
1
+ declare const config: {
2
+ disableWarning: boolean;
3
+ };
4
4
  /**
5
5
  * 设置禁止warning提示
6
6
  * @static
@@ -8,5 +8,6 @@ export namespace config {
8
8
  * @since 3.6.1
9
9
  * @param {boolean} bool 是否禁止warning提示
10
10
  */
11
- export function setDisableWarning(bool: boolean): void;
12
- export const version: string;
11
+ declare function setDisableWarning(bool: boolean): void;
12
+ declare const version: string;
13
+ export { config, setDisableWarning, version };
@@ -1,2 +1,2 @@
1
- export const MAX_SAFE_INTEGER: number;
2
- export const MIN_SAFE_INTEGER: number;
1
+ export declare const MAX_SAFE_INTEGER: number;
2
+ export declare const MIN_SAFE_INTEGER: number;
@@ -1,4 +1,3 @@
1
- export default convertToString;
2
1
  /**
3
2
  * 转换为字符串
4
3
  *
@@ -6,3 +5,4 @@ export default convertToString;
6
5
  * @returns {string} 字符串
7
6
  */
8
7
  declare function convertToString(value: any): string;
8
+ export default convertToString;
@@ -1,7 +1,7 @@
1
- export default devWarn;
2
1
  /**
3
2
  * 打印警告信息
4
3
  *
5
4
  * @param {any[]} args 打印的信息
6
5
  */
7
6
  declare function devWarn(...args: any[]): void;
7
+ export default devWarn;
@@ -1,17 +1,23 @@
1
+ /**
2
+ * 参考: https://github.com/nefe/number-precision/blob/master/src/index.ts
3
+ *
4
+ * 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
5
+ * 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
6
+ */
1
7
  /**
2
8
  * 将值转换为有效数值
3
9
  *
4
10
  * @param {*} value 要转换的值
5
11
  * @returns {number|string} 有效数值
6
12
  */
7
- export function transformEffectiveNumber(value: any): number | string;
13
+ export declare function transformEffectiveNumber(value: any): string | number;
8
14
  /**
9
15
  * 是否为科学计数法数字
10
16
  *
11
17
  * @param {string} num 检查值
12
18
  * @returns {boolean}
13
19
  */
14
- export function isScientificNumber(num: string): boolean;
20
+ export declare function isScientificNumber(num: string): boolean;
15
21
  /**
16
22
  * 把错误的数据转正
17
23
  *
@@ -22,34 +28,34 @@ export function isScientificNumber(num: string): boolean;
22
28
  *
23
29
  * strip(0.09999999999999998)=0.1
24
30
  */
25
- export function strip(num: number, precision?: number | undefined): number;
31
+ export declare function strip(num: number, precision?: number): number;
26
32
  /**
27
33
  * 计算数字的小数点长度,支持科学记数法
28
34
  *
29
35
  * @param {number|string} num 输入数
30
36
  * @returns {number} 小数点长度
31
37
  */
32
- export function digitLength(num: number | string): number;
38
+ export declare function digitLength(num: number | string): number;
33
39
  /**
34
40
  * 把小数转成整数,支持科学计数法。如果是小数则放大成整数
35
41
  *
36
42
  * @param {number|string} num 输入数
37
43
  * @returns {number}
38
44
  */
39
- export function float2Fixed(num: number | string): number;
45
+ export declare function float2Fixed(num: number | string): number;
40
46
  /**
41
47
  * 检测数字是否越界,如果越界给出提示
48
+ *
42
49
  * @param {number} num 输入数
43
- * @returns
44
50
  */
45
- export function checkBoundary(num: number): void;
51
+ export declare function checkBoundary(num: number): void;
46
52
  /**
47
53
  * 去掉左边数字0
48
54
  *
49
55
  * @param {string} num 数字字符串
50
56
  * @returns {string}
51
57
  */
52
- export function trimLeftZero(num: string): string;
58
+ export declare function trimLeftZero(num: string): string;
53
59
  /**
54
60
  * 科学计数法转换成普通数字
55
61
  *
@@ -60,4 +66,4 @@ export function trimLeftZero(num: string): string;
60
66
  * @param {string | number} num 科学计数法数字
61
67
  * @returns {string | number} 转换后的数字字符串
62
68
  */
63
- export function scientificToNumber(num: string | number): string | number;
69
+ export declare function scientificToNumber(num: number | string): string | number;
@@ -18,4 +18,11 @@ import isWeakMap from './isWeakMap';
18
18
  import isSet from './isSet';
19
19
  import isWeakSet from './isWeakSet';
20
20
  import isUndefined from './isUndefined';
21
+ /**
22
+ * 类型检测
23
+ *
24
+ * @module Type
25
+ * @ignore
26
+ * @since 1.1.0
27
+ */
21
28
  export { isArguments, isArray, isArrayBuffer, isBlob, isBoolean, isDate, isError, isFunction, isObject, isNull, isNaN, isNumber, isRegExp, isString, isSymbol, isMap, isWeakMap, isSet, isWeakSet, isUndefined };
@@ -1,4 +1,3 @@
1
- export default isArguments;
2
1
  /**
3
2
  * 检查值是否为Arguments
4
3
  *
@@ -16,3 +15,4 @@ export default isArguments;
16
15
  * // => false
17
16
  */
18
17
  declare function isArguments(value: any): boolean;
18
+ export default isArguments;
@@ -1,4 +1,3 @@
1
- export default isArray;
2
1
  /**
3
2
  * 检查值是否为Array
4
3
  *
@@ -16,3 +15,4 @@ export default isArray;
16
15
  * // => false
17
16
  */
18
17
  declare function isArray(value: any): boolean;
18
+ export default isArray;
@@ -1,4 +1,3 @@
1
- export default isArrayBuffer;
2
1
  /**
3
2
  * 检查值是否为ArrayBuffer对象
4
3
  *
@@ -19,3 +18,4 @@ export default isArrayBuffer;
19
18
  * // => false
20
19
  */
21
20
  declare function isArrayBuffer(value: any): boolean;
21
+ export default isArrayBuffer;
@@ -1,4 +1,3 @@
1
- export default isBlob;
2
1
  /**
3
2
  * 检查值是否为Blob对象<br/><br/>
4
3
  *
@@ -21,3 +20,4 @@ export default isBlob;
21
20
  * // => false
22
21
  */
23
22
  declare function isBlob(value: any): boolean;
23
+ export default isBlob;
@@ -1,4 +1,3 @@
1
- export default isBoolean;
2
1
  /**
3
2
  * 检查值是否为Boolean
4
3
  *
@@ -16,3 +15,4 @@ export default isBoolean;
16
15
  * // => false
17
16
  */
18
17
  declare function isBoolean(value: any): boolean;
18
+ export default isBoolean;
@@ -1,4 +1,3 @@
1
- export default isDate;
2
1
  /**
3
2
  * 检查值是否为Date
4
3
  *
@@ -16,3 +15,4 @@ export default isDate;
16
15
  * // => false
17
16
  */
18
17
  declare function isDate(value: any): boolean;
18
+ export default isDate;
@@ -1,4 +1,3 @@
1
- export default isError;
2
1
  /**
3
2
  * 检查值是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError|DOMException
4
3
  *
@@ -16,3 +15,4 @@ export default isError;
16
15
  * // => false
17
16
  */
18
17
  declare function isError(value: any): boolean;
18
+ export default isError;
@@ -1,4 +1,3 @@
1
- export default isFunction;
2
1
  /**
3
2
  * 检查值是否为Function|AsyncFunction|GeneratorFunction|Proxy
4
3
  *
@@ -16,3 +15,4 @@ export default isFunction;
16
15
  * // => false
17
16
  */
18
17
  declare function isFunction(value: any): boolean;
18
+ export default isFunction;
@@ -1,4 +1,3 @@
1
- export default isMap;
2
1
  /**
3
2
  * 检查值是否为Map
4
3
  *
@@ -16,3 +15,4 @@ export default isMap;
16
15
  * // => false
17
16
  */
18
17
  declare function isMap(value: any): boolean;
18
+ export default isMap;
@@ -1,4 +1,3 @@
1
- export default _isNaN;
2
1
  /**
3
2
  * 检查值是否为NaN
4
3
  *
@@ -16,3 +15,4 @@ export default _isNaN;
16
15
  * // => false
17
16
  */
18
17
  declare function _isNaN(value: any): boolean;
18
+ export default _isNaN;
@@ -1,4 +1,3 @@
1
- export default isNil;
2
1
  /**
3
2
  * 检查值是否为 undefined 或 null
4
3
  *
@@ -9,3 +8,4 @@ export default isNil;
9
8
  * @returns {boolean} 是否为 undefined 或 null
10
9
  */
11
10
  declare function isNil(value: any): boolean;
11
+ export default isNil;
@@ -1,4 +1,3 @@
1
- export default isNull;
2
1
  /**
3
2
  * 检查值是否为Null
4
3
  *
@@ -16,3 +15,4 @@ export default isNull;
16
15
  * // => false
17
16
  */
18
17
  declare function isNull(value: any): boolean;
18
+ export default isNull;
@@ -1,4 +1,3 @@
1
- export default isNumber;
2
1
  /**
3
2
  * 检查值是否为Number
4
3
  *
@@ -25,3 +24,4 @@ export default isNumber;
25
24
  * // => false
26
25
  */
27
26
  declare function isNumber(value: any): boolean;
27
+ export default isNumber;
@@ -1,4 +1,3 @@
1
- export default isObject;
2
1
  /**
3
2
  * 检查值是否为Object
4
3
  *
@@ -19,3 +18,4 @@ export default isObject;
19
18
  * // => false
20
19
  */
21
20
  declare function isObject(value: any): boolean;
21
+ export default isObject;
@@ -1,4 +1,3 @@
1
- export default isRegExp;
2
1
  /**
3
2
  * 检查值是否为RegExp
4
3
  *
@@ -16,3 +15,4 @@ export default isRegExp;
16
15
  * // => false
17
16
  */
18
17
  declare function isRegExp(value: any): boolean;
18
+ export default isRegExp;
@@ -1,4 +1,3 @@
1
- export default isSet;
2
1
  /**
3
2
  * 检查值是否为Set
4
3
  *
@@ -16,3 +15,4 @@ export default isSet;
16
15
  * // => false
17
16
  */
18
17
  declare function isSet(value: any): boolean;
18
+ export default isSet;
@@ -1,4 +1,3 @@
1
- export default isString;
2
1
  /**
3
2
  * 检查值是否为String
4
3
  *
@@ -16,3 +15,4 @@ export default isString;
16
15
  * // => false
17
16
  */
18
17
  declare function isString(value: any): boolean;
18
+ export default isString;
@@ -1,4 +1,3 @@
1
- export default isSymbol;
2
1
  /**
3
2
  * 检查值是否为Symbol
4
3
  *
@@ -16,3 +15,4 @@ export default isSymbol;
16
15
  * // => false
17
16
  */
18
17
  declare function isSymbol(value: any): boolean;
18
+ export default isSymbol;
@@ -1,4 +1,3 @@
1
- export default isType;
2
1
  /**
3
2
  * 检测值的 `toString` 类型
4
3
  *
@@ -9,3 +8,4 @@ export default isType;
9
8
  * @returns {boolean} 返回值的 `toString` 类型是否匹配
10
9
  */
11
10
  declare function isType(value: any, typename: string): boolean;
11
+ export default isType;
@@ -1,4 +1,3 @@
1
- export default isUndefined;
2
1
  /**
3
2
  * 检查值是否为Undefined
4
3
  *
@@ -19,3 +18,4 @@ export default isUndefined;
19
18
  * // => false
20
19
  */
21
20
  declare function isUndefined(value: any): boolean;
21
+ export default isUndefined;
@@ -1,4 +1,3 @@
1
- export default isWeakMap;
2
1
  /**
3
2
  * 检查值是否为WeakMap
4
3
  *
@@ -16,3 +15,4 @@ export default isWeakMap;
16
15
  * // => false
17
16
  */
18
17
  declare function isWeakMap(value: any): boolean;
18
+ export default isWeakMap;
@@ -1,4 +1,3 @@
1
- export default isWeakSet;
2
1
  /**
3
2
  * 检查值是否为WeakSet
4
3
  *
@@ -16,3 +15,4 @@ export default isWeakSet;
16
15
  * // => false
17
16
  */
18
17
  declare function isWeakSet(value: any): boolean;
18
+ export default isWeakSet;
@@ -1,45 +1,7 @@
1
- export default validatePassword;
2
- /**
3
- * - 验证密码的包含内容
4
- */
5
- export type PasswordContaines = {
6
- /**
7
- * - 包含数字
8
- */
9
- number: boolean;
10
- /**
11
- * - 包含小写字母
12
- */
13
- lowerCaseLetter: boolean;
14
- /**
15
- * - 包含大写字母
16
- */
17
- upperCaseLetter: boolean;
18
- /**
19
- * - 包含特殊字符
20
- */
21
- specialCharacter: boolean;
22
- /**
23
- * - 包含非法字符
24
- */
25
- unallowableCharacter: boolean;
26
- };
27
- /**
28
- * - 验证结果
29
- */
30
- export type ValidatePasswordReturn = {
31
- /**
32
- * - 验证结果,根据密码强度、是否包含非法字符得出
33
- */
34
- validated: boolean;
35
- /**
36
- * - 强度级别,包含数字/大小写字母/特殊字符
37
- */
38
- level: number;
39
- /**
40
- * - 包含内容
41
- */
42
- containes: PasswordContaines;
1
+ type Options = {
2
+ level?: number;
3
+ ignoreCase?: boolean;
4
+ special?: string;
43
5
  };
44
6
  /**
45
7
  * @typedef {Object} PasswordContaines - 验证密码的包含内容
@@ -61,7 +23,7 @@ export type ValidatePasswordReturn = {
61
23
  * @static
62
24
  * @alias module:Validator.validatePassword
63
25
  * @since 3.7.0
64
- * @see {@link https://baike.baidu.com/item/ASCII#3|ASCII}
26
+ * @see {@link https://baike.baidu.com/item/ASCII#3 | ASCII}
65
27
  * @param {string} value 要检测的值
66
28
  * @param {Object} [options] 配置项
67
29
  * @param {number} [options.level=2] 密码强度 1-包含一种字符 2-包含两种字符 3-包含三种字符。(大写字母、小写字母、数字、特殊字符)
@@ -127,8 +89,15 @@ export type ValidatePasswordReturn = {
127
89
  * }
128
90
  * }
129
91
  */
130
- declare function validatePassword(value: string, options?: {
131
- level?: number | undefined;
132
- ignoreCase?: boolean | undefined;
133
- special?: string | undefined;
134
- } | undefined): ValidatePasswordReturn;
92
+ declare function validatePassword(value: string, options?: Options): {
93
+ validated: boolean;
94
+ level: number;
95
+ containes: {
96
+ number: boolean;
97
+ lowerCaseLetter: boolean;
98
+ upperCaseLetter: boolean;
99
+ specialCharacter: boolean;
100
+ unallowableCharacter: boolean;
101
+ };
102
+ };
103
+ export default validatePassword;
@@ -1,4 +1,3 @@
1
- export default waitTime;
2
1
  /**
3
2
  * 等待时间返回 Promise 。常用于异步方法中延时。
4
3
  *
@@ -19,4 +18,5 @@ export default waitTime;
19
18
  * });
20
19
  *
21
20
  */
22
- declare function waitTime(time?: number | undefined): Promise<void>;
21
+ declare function waitTime(time?: number): Promise<unknown>;
22
+ export default waitTime;