util-helpers 4.13.1 → 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.
Files changed (174) hide show
  1. package/README.md +16 -6
  2. package/dist/util-helpers.js +935 -536
  3. package/dist/util-helpers.js.map +1 -1
  4. package/dist/util-helpers.min.js +1 -1
  5. package/dist/util-helpers.min.js.map +1 -1
  6. package/esm/blobToDataURL.js +2 -4
  7. package/esm/bytesToSize.js +13 -5
  8. package/esm/calculateCursorPosition.js +7 -12
  9. package/esm/dataURLToBlob.js +2 -5
  10. package/esm/divide.js +9 -13
  11. package/esm/findTreeNode.js +66 -0
  12. package/esm/findTreeSelect.js +80 -0
  13. package/esm/formatBankCard.js +11 -11
  14. package/esm/formatMobile.js +11 -14
  15. package/esm/formatMoney.js +24 -35
  16. package/esm/index.js +9 -4
  17. package/esm/isBankCard.js +9 -13
  18. package/esm/isBusinessLicense.js +19 -20
  19. package/esm/isChinese.js +6 -6
  20. package/esm/isEmail.js +3 -3
  21. package/esm/isHMCard.js +3 -3
  22. package/esm/isIPv4.js +3 -3
  23. package/esm/isIPv6.js +3 -3
  24. package/esm/isIdCard.js +9 -17
  25. package/esm/isMobile.js +3 -3
  26. package/esm/isPassport.js +3 -3
  27. package/esm/isPassword.js +6 -7
  28. package/esm/isPostcode.js +3 -3
  29. package/esm/isPromiseLike.js +0 -2
  30. package/esm/isQQ.js +3 -3
  31. package/esm/isSocialCreditCode.js +29 -28
  32. package/esm/isSwiftCode.js +1 -2
  33. package/esm/isTWCard.js +6 -7
  34. package/esm/isTelephone.js +3 -3
  35. package/esm/isUrl.js +7 -3
  36. package/esm/isVehicle.js +3 -3
  37. package/esm/isWX.js +3 -3
  38. package/esm/listToTree.js +122 -0
  39. package/esm/minus.js +7 -11
  40. package/esm/normalizeString.js +1 -3
  41. package/esm/numberToChinese.js +43 -52
  42. package/esm/padZero.js +1 -5
  43. package/esm/parseIdCard.js +27 -23
  44. package/esm/plus.js +7 -11
  45. package/esm/randomString.js +2 -8
  46. package/esm/replaceChar.js +11 -16
  47. package/esm/round.js +4 -5
  48. package/esm/safeDate.js +5 -7
  49. package/esm/setDataURLPrefix.js +0 -1
  50. package/esm/strlen.js +1 -5
  51. package/esm/times.js +7 -11
  52. package/esm/transformFieldNames.doc.js +34 -0
  53. package/esm/transformFieldNames.js +98 -0
  54. package/esm/transformFieldNames.type.js +19 -0
  55. package/esm/treeToList.js +88 -0
  56. package/esm/utils/config.js +4 -4
  57. package/esm/utils/constants.js +2 -2
  58. package/esm/utils/convertToString.js +1 -2
  59. package/esm/utils/devWarn.js +1 -3
  60. package/esm/utils/math.util.js +20 -29
  61. package/esm/utils/type/index.js +1 -1
  62. package/esm/utils/type/isArguments.js +1 -2
  63. package/esm/utils/type/isArray.js +1 -2
  64. package/esm/utils/type/isBoolean.js +1 -2
  65. package/esm/utils/type/isDate.js +1 -2
  66. package/esm/utils/type/isError.js +1 -2
  67. package/esm/utils/type/isFunction.js +1 -2
  68. package/esm/utils/type/isMap.js +1 -2
  69. package/esm/utils/type/isNaN.js +1 -2
  70. package/esm/utils/type/isNil.js +1 -2
  71. package/esm/utils/type/isNull.js +0 -1
  72. package/esm/utils/type/isNumber.js +1 -2
  73. package/esm/utils/type/isObject.js +0 -3
  74. package/esm/utils/type/isRegExp.js +1 -2
  75. package/esm/utils/type/isSet.js +1 -2
  76. package/esm/utils/type/isString.js +1 -2
  77. package/esm/utils/type/isSymbol.js +1 -2
  78. package/esm/utils/type/isType.js +1 -2
  79. package/esm/utils/type/isUndefined.js +0 -1
  80. package/esm/utils/type/isWeakMap.js +1 -2
  81. package/esm/utils/type/isWeakSet.js +1 -2
  82. package/esm/validatePassword.js +27 -50
  83. package/esm/waitTime.js +0 -1
  84. package/lib/blobToDataURL.js +2 -5
  85. package/lib/bytesToSize.js +13 -6
  86. package/lib/calculateCursorPosition.js +4 -13
  87. package/lib/dataURLToBlob.js +2 -6
  88. package/lib/divide.js +8 -22
  89. package/lib/findTreeNode.js +76 -0
  90. package/lib/findTreeSelect.js +86 -0
  91. package/lib/formatBankCard.js +10 -13
  92. package/lib/formatMobile.js +10 -16
  93. package/lib/formatMoney.js +25 -47
  94. package/lib/index.js +115 -126
  95. package/lib/isBankCard.js +7 -15
  96. package/lib/isBusinessLicense.js +17 -22
  97. package/lib/isChinese.js +6 -9
  98. package/lib/isEmail.js +1 -5
  99. package/lib/isHMCard.js +1 -5
  100. package/lib/isIPv4.js +1 -5
  101. package/lib/isIPv6.js +1 -5
  102. package/lib/isIdCard.js +7 -19
  103. package/lib/isMobile.js +1 -5
  104. package/lib/isPassport.js +1 -5
  105. package/lib/isPassword.js +5 -9
  106. package/lib/isPostcode.js +1 -5
  107. package/lib/isPromiseLike.js +1 -4
  108. package/lib/isQQ.js +1 -5
  109. package/lib/isSocialCreditCode.js +27 -30
  110. package/lib/isSwiftCode.js +1 -5
  111. package/lib/isTWCard.js +4 -9
  112. package/lib/isTelephone.js +1 -5
  113. package/lib/isUrl.js +5 -5
  114. package/lib/isVehicle.js +1 -5
  115. package/lib/isWX.js +1 -5
  116. package/lib/listToTree.js +131 -0
  117. package/lib/minus.js +6 -20
  118. package/lib/normalizeString.js +0 -6
  119. package/lib/numberToChinese.js +41 -55
  120. package/lib/padZero.js +0 -7
  121. package/lib/parseIdCard.js +30 -29
  122. package/lib/plus.js +6 -20
  123. package/lib/randomString.js +2 -8
  124. package/lib/replaceChar.js +10 -18
  125. package/lib/round.js +3 -9
  126. package/lib/safeDate.js +4 -13
  127. package/lib/setDataURLPrefix.js +0 -2
  128. package/lib/strlen.js +0 -7
  129. package/lib/times.js +6 -18
  130. package/lib/transformFieldNames.doc.js +41 -0
  131. package/lib/transformFieldNames.js +104 -0
  132. package/lib/transformFieldNames.type.js +5 -0
  133. package/lib/treeToList.js +96 -0
  134. package/lib/utils/config.js +6 -6
  135. package/lib/utils/constants.js +2 -2
  136. package/lib/utils/convertToString.js +0 -4
  137. package/lib/utils/devWarn.js +0 -4
  138. package/lib/utils/math.util.js +23 -45
  139. package/lib/utils/type/index.js +20 -39
  140. package/lib/utils/type/isArguments.js +0 -4
  141. package/lib/utils/type/isArray.js +0 -4
  142. package/lib/utils/type/isBoolean.js +0 -4
  143. package/lib/utils/type/isDate.js +0 -4
  144. package/lib/utils/type/isError.js +0 -4
  145. package/lib/utils/type/isFunction.js +0 -4
  146. package/lib/utils/type/isMap.js +0 -4
  147. package/lib/utils/type/isNaN.js +0 -4
  148. package/lib/utils/type/isNil.js +0 -5
  149. package/lib/utils/type/isNull.js +0 -2
  150. package/lib/utils/type/isNumber.js +0 -4
  151. package/lib/utils/type/isObject.js +1 -5
  152. package/lib/utils/type/isRegExp.js +0 -4
  153. package/lib/utils/type/isSet.js +0 -4
  154. package/lib/utils/type/isString.js +0 -4
  155. package/lib/utils/type/isSymbol.js +0 -4
  156. package/lib/utils/type/isType.js +1 -2
  157. package/lib/utils/type/isUndefined.js +0 -2
  158. package/lib/utils/type/isWeakMap.js +0 -4
  159. package/lib/utils/type/isWeakSet.js +0 -4
  160. package/lib/validatePassword.js +27 -53
  161. package/lib/waitTime.js +0 -2
  162. package/package.json +6 -5
  163. package/types/bytesToSize.d.ts +9 -1
  164. package/types/findTreeNode.d.ts +26 -0
  165. package/types/findTreeSelect.d.ts +26 -0
  166. package/types/formatBankCard.d.ts +3 -3
  167. package/types/formatMobile.d.ts +4 -4
  168. package/types/index.d.ts +5 -0
  169. package/types/isIdCard.d.ts +2 -0
  170. package/types/isUrl.d.ts +2 -0
  171. package/types/listToTree.d.ts +41 -0
  172. package/types/transformFieldNames.d.ts +34 -0
  173. package/types/transformFieldNames.type.d.ts +2 -0
  174. package/types/treeToList.d.ts +20 -0
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.utilHelpers = {}));
5
- }(this, (function (exports) { 'use strict';
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  /**
8
8
  * 检查值是否为Undefined
@@ -56,12 +56,12 @@
56
56
  * @param {*} value 检查值
57
57
  * @returns {boolean} 是否为 undefined 或 null
58
58
  */
59
-
60
59
  function isNil(value) {
61
60
  return isUndefined(value) || isNull(value);
62
61
  }
63
62
 
64
63
  var toString = Object.prototype.toString;
64
+
65
65
  /**
66
66
  * 检测值的 `toString` 类型
67
67
  *
@@ -71,7 +71,6 @@
71
71
  * @param {string} typename 类型名称
72
72
  * @returns {boolean} 返回值的 `toString` 类型是否匹配
73
73
  */
74
-
75
74
  function isType(value, typename) {
76
75
  return toString.call(value) === "[object ".concat(typename, "]");
77
76
  }
@@ -92,7 +91,6 @@
92
91
  * isString(1)
93
92
  * // => false
94
93
  */
95
-
96
94
  function isString(value) {
97
95
  return isType(value, 'String');
98
96
  }
@@ -103,7 +101,6 @@
103
101
  * @param {*} value 值
104
102
  * @returns {string} 字符串
105
103
  */
106
-
107
104
  function convertToString(value) {
108
105
  return isString(value) ? value : String(value);
109
106
  }
@@ -130,16 +127,16 @@
130
127
  * normalizeString('a'); // 'a'
131
128
  *
132
129
  */
133
-
134
130
  function normalizeString(value) {
135
131
  if (isNil(value)) {
136
132
  return '';
137
133
  }
138
-
139
134
  return convertToString(value);
140
135
  }
141
136
 
137
+ // 手机号码 11位数字,以1开头,第二位是3456789其中一个,后面再加9个数字
142
138
  var reg$c = /^1[3456789]\d{9}$/;
139
+
143
140
  /**
144
141
  * 检测值是否为手机号码
145
142
  *
@@ -154,13 +151,14 @@
154
151
  * isMobile('13000'); // false
155
152
  *
156
153
  */
157
-
158
154
  function isMobile(value) {
159
155
  var valueStr = normalizeString(value);
160
156
  return reg$c.test(valueStr);
161
157
  }
162
158
 
159
+ // 固定电话 支持区号和分机号 3~4位区号,以0开头;7~8位直播号,以2~9开头;1~6位分机号
163
160
  var reg$b = /^(0\d{2,3}\-)?([2-9]\d{6,7})(\-\d{1,6})?$/;
161
+
164
162
  /**
165
163
  * 检测值是否为固定电话
166
164
  *
@@ -181,13 +179,14 @@
181
179
  * isTelephone('021-22033212-123'); // true
182
180
  *
183
181
  */
184
-
185
182
  function isTelephone(value) {
186
183
  var valueStr = normalizeString(value);
187
184
  return reg$b.test(valueStr);
188
185
  }
189
186
 
187
+ // 邮政编码
190
188
  var reg$a = /^\d{6}$/;
189
+
191
190
  /**
192
191
  * 检测值是否为邮政编码,6位数字
193
192
  *
@@ -202,44 +201,42 @@
202
201
  * isPostcode('123'); // false
203
202
  *
204
203
  */
205
-
206
204
  function isPostcode(value) {
207
205
  var valueStr = normalizeString(value);
208
206
  return reg$a.test(valueStr);
209
207
  }
210
208
 
209
+ // 身份证号正则
211
210
  var regIdCard$1 = /^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|30|31)\d{3}(\d|X)?$/i;
211
+
212
212
  /**
213
213
  * 校验码计算
214
214
  *
215
215
  * @private
216
- * @see 参考 {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码|中华人民共和国公民身份号码}
217
- * @see 参考 {@link https://baike.baidu.com/item/居民身份证号码|居民身份证号码}
218
216
  * @param {string} id 身份证号码
219
217
  * @returns {boolean} 校验码是否正确
220
218
  */
221
-
222
219
  function check(id) {
223
220
  var index, sum, num;
224
-
225
221
  for (sum = index = 0; index < 17; index++) {
226
222
  sum += Math.pow(2, 17 - index) % 11 * Number(id[index]);
227
223
  }
228
-
229
224
  num = (12 - sum % 11) % 11;
230
-
231
225
  if (num < 10) {
232
226
  return num === Number(id[17]);
233
227
  } else {
234
228
  return id[17].toUpperCase() === 'X';
235
229
  }
236
230
  }
231
+
237
232
  /**
238
233
  * 检测值是否为18位身份证号码。<br/>宽松模式下,支持15位身份证号码
239
234
  *
240
235
  * @static
241
236
  * @alias module:Validator.isIdCard
242
237
  * @since 1.1.0
238
+ * @see 参考 {@link https://zh.wikipedia.org/wiki/中华人民共和国公民身份号码|中华人民共和国公民身份号码}
239
+ * @see 参考 {@link https://baike.baidu.com/item/居民身份证号码|居民身份证号码}
243
240
  * @param {*} value 要检测的值
244
241
  * @param {Object} [options] 配置项
245
242
  * @param {boolean} [options.loose=false] 宽松模式,支持15位身份证号码
@@ -260,32 +257,28 @@
260
257
  * isIdCard('320311770706001', { loose: true }); // true
261
258
  *
262
259
  */
263
-
264
-
265
260
  function isIdCard(value) {
266
261
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
267
262
  var _options$loose = options.loose,
268
- loose = _options$loose === void 0 ? false : _options$loose,
269
- _options$checkCode = options.checkCode,
270
- checkCode = _options$checkCode === void 0 ? true : _options$checkCode;
263
+ loose = _options$loose === void 0 ? false : _options$loose,
264
+ _options$checkCode = options.checkCode,
265
+ checkCode = _options$checkCode === void 0 ? true : _options$checkCode;
271
266
  var valueStr = normalizeString(value);
272
-
273
267
  if (valueStr.length === 15 && loose) {
274
268
  return regIdCard$1.test(valueStr);
275
269
  }
276
-
277
270
  if (valueStr.length === 18 && regIdCard$1.test(valueStr)) {
278
271
  if (checkCode) {
279
272
  return check(valueStr);
280
273
  }
281
-
282
274
  return true;
283
275
  }
284
-
285
276
  return false;
286
277
  }
287
278
 
279
+ // 邮箱
288
280
  var reg$9 = /^[\da-z]+([\-\.\_]?[\da-z]+)*@[\da-z]+([\-\.]?[\da-z]+)*(\.[a-z]{2,})+$/i;
281
+
289
282
  /**
290
283
  * 检测值是否为Email
291
284
  *
@@ -300,13 +293,14 @@
300
293
  * isEmail('123@'); // false
301
294
  *
302
295
  */
303
-
304
296
  function isEmail(value) {
305
297
  var valueStr = normalizeString(value);
306
298
  return reg$9.test(valueStr);
307
299
  }
308
300
 
301
+ // QQ号正则
309
302
  var reg$8 = /^[1-9]\d{4,10}$/;
303
+
310
304
  /**
311
305
  * 检测值是否为QQ号,非0开头,5至11位数字
312
306
  *
@@ -321,13 +315,14 @@
321
315
  * isQQ('123'); // false
322
316
  *
323
317
  */
324
-
325
318
  function isQQ(value) {
326
319
  var valueStr = normalizeString(value);
327
320
  return reg$8.test(valueStr);
328
321
  }
329
322
 
323
+ // 微信号 6至20位,以字母开头,字母,数字,减号(连接符),下划线
330
324
  var reg$7 = /^[a-z]([-_a-z0-9]{5,19})+$/i;
325
+
331
326
  /**
332
327
  * 检测值是否为微信号
333
328
  *
@@ -342,13 +337,14 @@
342
337
  * isWX('123'); // false
343
338
  *
344
339
  */
345
-
346
340
  function isWX(value) {
347
341
  var valueStr = normalizeString(value);
348
342
  return reg$7.test(valueStr);
349
343
  }
350
344
 
345
+ // 车牌号正则
351
346
  var reg$6 = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})|([A-Z0-9]{5}[DF])|([DF][A-Z0-9]{5}))$/;
347
+
352
348
  /**
353
349
  * 检测值是否为车牌号,支持新能源和非新能源车牌
354
350
  *
@@ -371,34 +367,34 @@
371
367
  * isVehicle('粤B12345F'); // true
372
368
  *
373
369
  */
374
-
375
370
  function isVehicle(value) {
376
371
  var valueStr = normalizeString(value);
377
372
  return reg$6.test(valueStr);
378
373
  }
379
374
 
380
- var reg$5 = /^[1-9]\d{9,20}$/; // 8~30位数字
375
+ // 非0开头,10~21位数字
376
+ var reg$5 = /^[1-9]\d{9,20}$/;
381
377
 
378
+ // 8~30位数字
382
379
  var regLoose = /^\d{8,30}$/;
380
+
383
381
  /**
384
382
  * luhn 计算校验位
385
383
  * @private
386
384
  * @param {string} numStr 银行卡前面数字
387
385
  * @returns {number}
388
386
  */
389
-
390
387
  function sumCheckCode$2(numStr) {
391
388
  var numArr = (numStr + '').replace(/\D/g, '').split('').reverse();
392
389
  var sum = 0;
393
-
394
390
  for (var i = 0; i < numArr.length; i++) {
395
391
  var currNum = parseInt(numArr[i]);
396
392
  sum += i % 2 === 0 ? currNum * 2 - (currNum > 4 ? 9 : 0) : currNum;
397
393
  }
398
-
399
394
  var mod = sum % 10;
400
395
  return mod !== 0 ? 10 - mod : 0;
401
396
  }
397
+
402
398
  /**
403
399
  * 检测值是否为银行卡号。正常模式(非0开头,10~21位数字)宽松模式(8~30位数字)
404
400
  *
@@ -421,29 +417,28 @@
421
417
  * isBankCard('123456789', { loose: true }); // true
422
418
  *
423
419
  */
424
-
425
-
426
420
  function isBankCard(value) {
427
421
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
428
422
  var _options$loose = options.loose,
429
- loose = _options$loose === void 0 ? false : _options$loose,
430
- _options$luhn = options.luhn,
431
- luhn = _options$luhn === void 0 ? false : _options$luhn;
423
+ loose = _options$loose === void 0 ? false : _options$loose,
424
+ _options$luhn = options.luhn,
425
+ luhn = _options$luhn === void 0 ? false : _options$luhn;
432
426
  var valueStr = normalizeString(value);
433
427
  var validateResult = loose ? regLoose.test(valueStr) : reg$5.test(valueStr);
434
-
435
428
  if (validateResult && luhn) {
436
429
  var precode = valueStr.substring(0, valueStr.length - 1);
437
430
  var checkCode = valueStr[valueStr.length - 1];
438
431
  return checkCode === String(sumCheckCode$2(precode));
439
432
  }
440
-
441
433
  return validateResult;
442
434
  }
443
435
 
444
- var baseReg$1 = /^[\dA-HJ-NPQRTUWXY]{2}\d{6}[\dA-HJ-NPQRTUWXY]{10}$/; // 基础字符组成
436
+ // 基础规则,由18位数字和大写字母组成,不使用I、O、Z、S、V。
437
+ var baseReg$1 = /^[\dA-HJ-NPQRTUWXY]{2}\d{6}[\dA-HJ-NPQRTUWXY]{10}$/;
445
438
 
439
+ // 基础字符组成
446
440
  var baseCodeArr = '0123456789ABCDEFGHJKLMNPQRTUWXY'.split('');
441
+
447
442
  /**
448
443
  * 计算校验码
449
444
  *
@@ -452,31 +447,31 @@
452
447
  * @param {string} preCode 统一代码前17位
453
448
  * @returns {string} 校验码
454
449
  */
455
-
456
450
  function sumCheckCode$1(preCode) {
457
- var total = 0; // 计算字符位置对应序号和加权因子的乘积,总和
451
+ var total = 0;
458
452
 
453
+ // 计算字符位置对应序号和加权因子的乘积,总和
459
454
  var _loop = function _loop(i) {
460
455
  // 字符位置对应的基础编码序号
461
456
  var index = baseCodeArr.findIndex(function (item) {
462
457
  return item === preCode[i];
463
- }); // 加权因子
464
-
465
- var wf = Math.pow(3, i) % 31; // 计算序号和加权因子的乘积,并计算级数之和
466
-
458
+ });
459
+ // 加权因子
460
+ var wf = Math.pow(3, i) % 31;
461
+ // 计算序号和加权因子的乘积,并计算级数之和
467
462
  total += index * wf;
468
463
  };
469
-
470
464
  for (var i = 0; i < 17; i++) {
471
465
  _loop(i);
472
- } // 计算整数求余函数MOD
473
-
474
-
475
- var remainder = total % 31; // 校验码字符值序号
466
+ }
476
467
 
468
+ // 计算整数求余函数MOD
469
+ var remainder = total % 31;
470
+ // 校验码字符值序号
477
471
  var checkCodeIndex = remainder !== 0 ? 31 - remainder : 0;
478
472
  return baseCodeArr[checkCodeIndex];
479
473
  }
474
+
480
475
  /**
481
476
  * 检测值是否为统一社会信用代码,也叫三证合一组织代码。由18位数字和大写字母组成,不使用I、O、Z、S、V。
482
477
  *
@@ -499,29 +494,28 @@
499
494
  * isSocialCreditCode('91350100M000100Y', { checkCode: false }); // false
500
495
  *
501
496
  */
502
-
503
-
504
497
  function isSocialCreditCode(value) {
505
498
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
506
- var valueStr = normalizeString(value); // @ts-ignore
499
+ var valueStr = normalizeString(value);
500
+ // @ts-ignore
507
501
  // TODO 下个版本废弃 loose
508
-
509
502
  var _options$loose = options.loose,
510
- loose = _options$loose === void 0 ? false : _options$loose,
511
- _options$checkCode = options.checkCode,
512
- cc = _options$checkCode === void 0 ? true : _options$checkCode;
503
+ loose = _options$loose === void 0 ? false : _options$loose,
504
+ _options$checkCode = options.checkCode,
505
+ cc = _options$checkCode === void 0 ? true : _options$checkCode;
513
506
  var needCheckCode = !loose && cc;
514
- var passBaseRule = baseReg$1.test(valueStr); // 宽松模式 或 基础规则不通过直接返回
507
+ var passBaseRule = baseReg$1.test(valueStr);
515
508
 
509
+ // 宽松模式 或 基础规则不通过直接返回
516
510
  if (!needCheckCode || !passBaseRule) {
517
511
  return passBaseRule;
518
- } // 前17位
519
-
520
-
521
- var preCode = valueStr.substring(0, 17); // 校验码
522
-
523
- var lastCode = valueStr.substring(valueStr.length - 1); // 计算校验码
512
+ }
524
513
 
514
+ // 前17位
515
+ var preCode = valueStr.substring(0, 17);
516
+ // 校验码
517
+ var lastCode = valueStr.substring(valueStr.length - 1);
518
+ // 计算校验码
525
519
  var checkCode = sumCheckCode$1(preCode);
526
520
  return lastCode === checkCode;
527
521
  }
@@ -530,6 +524,7 @@
530
524
  // 禁用warning提示
531
525
  disableWarning: true
532
526
  };
527
+
533
528
  /**
534
529
  * 设置禁止warning提示
535
530
  * @static
@@ -537,24 +532,21 @@
537
532
  * @since 3.6.1
538
533
  * @param {boolean} bool 是否禁止warning提示
539
534
  */
540
-
541
535
  function setDisableWarning(bool) {
542
536
  config.disableWarning = !!bool;
543
- } // eslint-disable-next-line no-undef
544
-
537
+ }
545
538
 
546
- var version = "4.13.1";
539
+ // eslint-disable-next-line no-undef
540
+ var version = "4.14.0";
547
541
 
548
542
  /**
549
543
  * 打印警告信息
550
544
  *
551
545
  * @param {any[]} args 打印的信息
552
546
  */
553
-
554
547
  function devWarn() {
555
548
  if (!config.disableWarning) {
556
549
  var _console;
557
-
558
550
  (_console = console).warn.apply(_console, arguments);
559
551
  }
560
552
  }
@@ -563,6 +555,7 @@
563
555
  var regLowerCaseLetter = /[a-z]/;
564
556
  var regUpperCaseLetter = /[A-Z]/;
565
557
  var regAllNumberAndLetter = /[\d|a-z]/gi;
558
+
566
559
  /**
567
560
  * 是否包含数字
568
561
  *
@@ -570,10 +563,10 @@
570
563
  * @param {string} val 检查的值
571
564
  * @returns {boolean} 是否包含数字
572
565
  */
573
-
574
566
  function hasNumber(val) {
575
567
  return regNumber.test(val);
576
568
  }
569
+
577
570
  /**
578
571
  * 是否包含小写字母
579
572
  *
@@ -581,11 +574,10 @@
581
574
  * @param {string} val 检测的值
582
575
  * @returns {boolean} 是否包含小写字母
583
576
  */
584
-
585
-
586
577
  function hasLowerCaseLetter(val) {
587
578
  return regLowerCaseLetter.test(val);
588
579
  }
580
+
589
581
  /**
590
582
  * 是否包含大写字母
591
583
  *
@@ -593,11 +585,10 @@
593
585
  * @param {string} val 检测的值
594
586
  * @returns {boolean} 是否包含大写字母
595
587
  */
596
-
597
-
598
588
  function hasUpperCaseLetter(val) {
599
589
  return regUpperCaseLetter.test(val);
600
590
  }
591
+
601
592
  /**
602
593
  * 是否为十六进制
603
594
  *
@@ -605,11 +596,10 @@
605
596
  * @param {string} val 检测的值
606
597
  * @returns {boolean} 是否为十六进制
607
598
  */
608
-
609
-
610
599
  function hasHex(val) {
611
600
  return val.indexOf('\\x') > -1 || val.indexOf("\\u") > -1;
612
601
  }
602
+
613
603
  /**
614
604
  * 是否包含特殊字符
615
605
  *
@@ -618,35 +608,28 @@
618
608
  * @param {string} chars 特殊字符
619
609
  * @returns {boolean} 是否包含特殊字符
620
610
  */
621
-
622
-
623
611
  function hasSpecialCharacter(val, chars) {
624
612
  if (!chars || !val) {
625
613
  return false;
626
614
  }
627
-
628
615
  var specialChars = val.replace(regAllNumberAndLetter, '');
629
-
630
616
  if (!specialChars) {
631
617
  return false;
632
618
  }
633
-
634
619
  var regChars = hasHex(chars) ? new RegExp("[".concat(chars, "]")) : null;
635
-
636
620
  if (regChars) {
637
621
  return regChars.test(specialChars);
638
622
  }
639
-
640
623
  var ret = false;
641
624
  specialChars.split('').some(function (charItem) {
642
625
  if (chars.indexOf(charItem) > -1) {
643
626
  ret = true;
644
627
  }
645
-
646
628
  return ret;
647
629
  });
648
630
  return ret;
649
631
  }
632
+
650
633
  /**
651
634
  * 是否包含非法字符
652
635
  *
@@ -655,37 +638,30 @@
655
638
  * @param {string} chars 特殊字符
656
639
  * @returns {boolean} 是否包含非法字符
657
640
  */
658
-
659
-
660
641
  function hasUnallowableCharacter(val, chars) {
661
642
  if (!val) {
662
643
  return false;
663
644
  }
664
-
665
645
  var specialChars = val.replace(regAllNumberAndLetter, '');
666
-
667
646
  if (!specialChars) {
668
647
  return false;
669
648
  } else if (!chars) {
670
649
  return true;
671
650
  }
672
-
673
651
  var regChars = hasHex(chars) ? new RegExp("[^".concat(chars, "]")) : null;
674
-
675
652
  if (regChars) {
676
653
  return regChars.test(specialChars);
677
654
  }
678
-
679
655
  var ret = false;
680
656
  specialChars.split('').some(function (charItem) {
681
657
  if (chars.indexOf(charItem) === -1) {
682
658
  ret = true;
683
659
  }
684
-
685
660
  return ret;
686
661
  });
687
662
  return ret;
688
663
  }
664
+
689
665
  /**
690
666
  * @typedef {Object} PasswordContaines - 验证密码的包含内容
691
667
  * @property {boolean} number - 包含数字
@@ -774,40 +750,36 @@
774
750
  * }
775
751
  * }
776
752
  */
777
-
778
-
779
753
  function validatePassword(value) {
780
754
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
781
755
  var _options$level = options.level,
782
- level = _options$level === void 0 ? 2 : _options$level,
783
- _options$ignoreCase = options.ignoreCase,
784
- ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
785
- _options$special = options.special,
786
- special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
756
+ level = _options$level === void 0 ? 2 : _options$level,
757
+ _options$ignoreCase = options.ignoreCase,
758
+ ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
759
+ _options$special = options.special,
760
+ special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
787
761
  var valStr = value;
788
-
789
762
  if (typeof value !== 'string') {
790
763
  devWarn("[validatePassword] value must be a string.");
791
764
  valStr = '';
792
765
  }
793
-
794
- var currentLevel = 0; // 包含数字
795
-
796
- var containesNumber = hasNumber(valStr); // 包含小写字母
797
-
798
- var containesLowerCaseLetter = hasLowerCaseLetter(valStr); // 包含大写字母
799
-
800
- var containesUpperCaseLetter = hasUpperCaseLetter(valStr); // 包含特殊字符
801
-
802
- var containesSpecialCharacter = hasSpecialCharacter(valStr, special); // 包含非法字符,即含有非数字字母特殊字符以外的其他字符
803
-
766
+ var currentLevel = 0;
767
+
768
+ // 包含数字
769
+ var containesNumber = hasNumber(valStr);
770
+ // 包含小写字母
771
+ var containesLowerCaseLetter = hasLowerCaseLetter(valStr);
772
+ // 包含大写字母
773
+ var containesUpperCaseLetter = hasUpperCaseLetter(valStr);
774
+ // 包含特殊字符
775
+ var containesSpecialCharacter = hasSpecialCharacter(valStr, special);
776
+ // 包含非法字符,即含有非数字字母特殊字符以外的其他字符
804
777
  var containesUnallowableCharacter = hasUnallowableCharacter(valStr, special);
805
-
806
778
  if (containesNumber) {
807
779
  currentLevel += 1;
808
- } // 不区分大小写
809
-
780
+ }
810
781
 
782
+ // 不区分大小写
811
783
  if (ignoreCase) {
812
784
  if (containesLowerCaseLetter || containesUpperCaseLetter) {
813
785
  currentLevel += 1;
@@ -817,17 +789,15 @@
817
789
  if (containesLowerCaseLetter) {
818
790
  currentLevel += 1;
819
791
  }
820
-
821
792
  if (containesUpperCaseLetter) {
822
793
  currentLevel += 1;
823
794
  }
824
795
  }
825
-
826
796
  if (containesSpecialCharacter) {
827
797
  currentLevel += 1;
828
- } // 验证结果
829
-
798
+ }
830
799
 
800
+ // 验证结果
831
801
  var validated = currentLevel >= level && !containesUnallowableCharacter;
832
802
  return {
833
803
  validated: validated,
@@ -875,15 +845,14 @@
875
845
  * isPassword(' _Aa12345678', {level: 3, ignoreCase: true}); // false
876
846
  *
877
847
  */
878
-
879
848
  function isPassword(value) {
880
849
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
881
850
  var _options$level = options.level,
882
- level = _options$level === void 0 ? 2 : _options$level,
883
- _options$ignoreCase = options.ignoreCase,
884
- ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
885
- _options$special = options.special,
886
- special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
851
+ level = _options$level === void 0 ? 2 : _options$level,
852
+ _options$ignoreCase = options.ignoreCase,
853
+ ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
854
+ _options$special = options.special,
855
+ special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
887
856
  return validatePassword(value, {
888
857
  level: level,
889
858
  ignoreCase: ignoreCase,
@@ -891,7 +860,9 @@
891
860
  }).validated;
892
861
  }
893
862
 
863
+ // 护照号 9位,包括首字母和数字;支持 普通护照(E*)、外交护照(DE)、公务护照(SE)、公务普通护照(PE)、香港特区护照(K/KJ/H*)、澳门特区护照(MA/MB/M*)
894
864
  var reg$4 = /^((e[\da-z])|(de)|(se)|(pe)|([khm][\da-z]))[\da-z]{7}$/i;
865
+
895
866
  /**
896
867
  * 检测值是否为护照号
897
868
  * 支持普通护照(E*)、外交护照(DE)、公务护照(SE)、公务普通护照(PE)、香港特区护照(K/KJ/H*)、澳门特区护照(MA/MB/M*),注意不区分大小写
@@ -908,7 +879,6 @@
908
879
  * isPassport('abc'); // false
909
880
  *
910
881
  */
911
-
912
882
  function isPassport(value) {
913
883
  var valueStr = normalizeString(value);
914
884
  return reg$4.test(valueStr);
@@ -936,9 +906,11 @@
936
906
  var chineseRegExp = '^' + chineseDictionary.chineseBasic + '+$';
937
907
  var chineseWithExtend = '(?:' + chineseDictionary.chineseBasic + '|' + chineseDictionary.chineseExtend + '|' + chineseDictionary.chineseExtendA + '|' + chineseDictionary.chineseExtendB + '|' + chineseDictionary.chineseExtendC + '|' + chineseDictionary.chineseExtendD + '|' + chineseDictionary.chineseExtendE + '|' + chineseDictionary.chineseExtendF + ')';
938
908
  var looseChineseExtendRegExp = chineseWithExtend + '+';
939
- var chineseExtendRegExp = '^' + chineseWithExtend + '+$'; // eslint-disable-next-line no-prototype-builtins
909
+ var chineseExtendRegExp = '^' + chineseWithExtend + '+$';
940
910
 
911
+ // eslint-disable-next-line no-prototype-builtins
941
912
  var supportRegExpUnicode = RegExp.prototype.hasOwnProperty('unicode');
913
+
942
914
  /**
943
915
  * 检测值是否为中文
944
916
  *
@@ -970,13 +942,12 @@
970
942
  * isChinese('𠮷aa', { useExtend: true, loose: true }); // true
971
943
  *
972
944
  */
973
-
974
945
  function isChinese(value) {
975
946
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
976
947
  var _options$loose = options.loose,
977
- loose = _options$loose === void 0 ? false : _options$loose,
978
- _options$useExtend = options.useExtend,
979
- useExtend = _options$useExtend === void 0 ? false : _options$useExtend;
948
+ loose = _options$loose === void 0 ? false : _options$loose,
949
+ _options$useExtend = options.useExtend,
950
+ useExtend = _options$useExtend === void 0 ? false : _options$useExtend;
980
951
  var valueStr = normalizeString(value);
981
952
  var basicRegExp = loose ? looseChineseRegExp : chineseRegExp;
982
953
  var extendRegExp = loose ? looseChineseExtendRegExp : chineseExtendRegExp;
@@ -987,7 +958,9 @@
987
958
  return reg.test(valueStr);
988
959
  }
989
960
 
961
+ // ipv4正则
990
962
  var reg$3 = /^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
963
+
991
964
  /**
992
965
  * 检测值是否为ipv4
993
966
  *
@@ -1004,13 +977,14 @@
1004
977
  * isIPv4('0.0'); // false
1005
978
  *
1006
979
  */
1007
-
1008
980
  function isIPv4(value) {
1009
981
  var valueStr = normalizeString(value);
1010
982
  return reg$3.test(valueStr);
1011
983
  }
1012
984
 
985
+ // ipv6正则
1013
986
  var reg$2 = /^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){5}(((:[0-9A-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){4}(((:[0-9A-F]{1,4}){1,3})|((:[0-9A-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){3}(((:[0-9A-F]{1,4}){1,4})|((:[0-9A-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){2}(((:[0-9A-F]{1,4}){1,5})|((:[0-9A-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){1}(((:[0-9A-F]{1,4}){1,6})|((:[0-9A-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(:(((:[0-9A-F]{1,4}){1,7})|((:[0-9A-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:)))(%.+)?$/i;
987
+
1014
988
  /**
1015
989
  * 检测值是否为ipv6
1016
990
  *
@@ -1041,13 +1015,14 @@
1041
1015
  * isIPv6('192.168.1.1'); // false
1042
1016
  *
1043
1017
  */
1044
-
1045
1018
  function isIPv6(value) {
1046
1019
  var valueStr = normalizeString(value);
1047
1020
  return reg$2.test(valueStr);
1048
1021
  }
1049
1022
 
1023
+ // 标准格式如下:
1050
1024
  // [协议类型]://[服务器地址]:[端口号]/[资源层级UNIX文件路径][文件名]?[查询]#[片段ID]
1025
+
1051
1026
  // 完整格式如下:
1052
1027
  // [协议类型]://[访问资源需要的凭证信息]@[服务器地址]:[端口号]/[资源层级UNIX文件路径][文件名]?[查询]#[片段ID]
1053
1028
  //
@@ -1062,6 +1037,7 @@
1062
1037
  var hashReg = '#.*';
1063
1038
  var regWithProtocal = new RegExp("^".concat(protocalReg, "(?:").concat(credentialsReg, ")?(?:").concat(serverReg, ")(?:").concat(portReg, ")?(?:").concat(pathReg, ")*(?:").concat(searchReg, ")?(?:").concat(hashReg, ")?$"));
1064
1039
  var regNonProtocal = new RegExp("^(?:".concat(serverReg, ")(?:").concat(portReg, ")?(?:").concat(pathReg, ")*(?:").concat(searchReg, ")?(?:").concat(hashReg, ")?$"));
1040
+
1065
1041
  /**
1066
1042
  * 检测值是否为url
1067
1043
  *
@@ -1089,15 +1065,18 @@
1089
1065
  * isUrl('a.b:8080'); // true
1090
1066
  * isUrl('p://a.b'); // true
1091
1067
  * isUrl('p://a.b:8888'); // true
1068
+ * isUrl('中文域名.中文后缀'); // true
1069
+ * isUrl('中文域名.cn'); // true
1092
1070
  *
1093
1071
  */
1094
-
1095
1072
  function isUrl(value) {
1096
1073
  var valueStr = normalizeString(value);
1097
1074
  return regWithProtocal.test(valueStr) || regNonProtocal.test(valueStr);
1098
1075
  }
1099
1076
 
1077
+ // 基础规则,由14位数字本体码和1位数字校验码组成,其中本体码从左至右依次为:6位首次登记机关码、8位顺序码。
1100
1078
  var baseReg = /^\d{15}$/;
1079
+
1101
1080
  /**
1102
1081
  * 计算校验码
1103
1082
  *
@@ -1106,7 +1085,6 @@
1106
1085
  * @param {string} preCode 营业执照前14位
1107
1086
  * @returns {number} 校验码
1108
1087
  */
1109
-
1110
1088
  function sumCheckCode(preCode) {
1111
1089
  var retNum; // 校验位数字
1112
1090
 
@@ -1118,17 +1096,17 @@
1118
1096
  sj10 = sj10 === 0 ? 10 : sj10;
1119
1097
  var pj1 = sj10 * 2;
1120
1098
  pj = pj1 % 11;
1121
- } // 反模10计算
1122
-
1099
+ }
1123
1100
 
1101
+ // 反模10计算
1124
1102
  if (pj === 1) {
1125
1103
  retNum = 0;
1126
1104
  } else {
1127
1105
  retNum = 11 - pj;
1128
1106
  }
1129
-
1130
1107
  return retNum;
1131
1108
  }
1109
+
1132
1110
  /**
1133
1111
  * 检测值是否为营业执照号,也叫工商注册号。由14位数字本体码和1位数字校验码组成,其中本体码从左至右依次为:6位首次登记机关码、8位顺序码。
1134
1112
  *
@@ -1151,117 +1129,154 @@
1151
1129
  * isBusinessLicense('31011560098', { checkCode: false }); // false
1152
1130
  *
1153
1131
  */
1154
-
1155
-
1156
1132
  function isBusinessLicense(value) {
1157
1133
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1158
- var valueStr = normalizeString(value); // @ts-ignore
1134
+ var valueStr = normalizeString(value);
1135
+ // @ts-ignore
1159
1136
  // TODO 下个版本废弃 loose
1160
-
1161
1137
  var _options$loose = options.loose,
1162
- loose = _options$loose === void 0 ? false : _options$loose,
1163
- _options$checkCode = options.checkCode,
1164
- cc = _options$checkCode === void 0 ? true : _options$checkCode;
1138
+ loose = _options$loose === void 0 ? false : _options$loose,
1139
+ _options$checkCode = options.checkCode,
1140
+ cc = _options$checkCode === void 0 ? true : _options$checkCode;
1165
1141
  var needCheckCode = !loose && cc;
1166
- var passBaseRule = baseReg.test(valueStr); // 宽松模式 或 基础规则不通过直接返回
1142
+ var passBaseRule = baseReg.test(valueStr);
1167
1143
 
1144
+ // 宽松模式 或 基础规则不通过直接返回
1168
1145
  if (!needCheckCode || !passBaseRule) {
1169
1146
  return passBaseRule;
1170
- } // 前14位
1171
-
1172
-
1173
- var preCode = valueStr.substring(0, 14); // 校验码
1174
-
1175
- var lastCode = valueStr.substring(valueStr.length - 1); // 计算校验码
1147
+ }
1176
1148
 
1149
+ // 前14位
1150
+ var preCode = valueStr.substring(0, 14);
1151
+ // 校验码
1152
+ var lastCode = valueStr.substring(valueStr.length - 1);
1153
+ // 计算校验码
1177
1154
  var checkCode = sumCheckCode(preCode);
1178
1155
  return lastCode === String(checkCode);
1179
1156
  }
1180
1157
 
1158
+ function _iterableToArrayLimit(arr, i) {
1159
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
1160
+ if (null != _i) {
1161
+ var _s,
1162
+ _e,
1163
+ _x,
1164
+ _r,
1165
+ _arr = [],
1166
+ _n = !0,
1167
+ _d = !1;
1168
+ try {
1169
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
1170
+ if (Object(_i) !== _i) return;
1171
+ _n = !1;
1172
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
1173
+ } catch (err) {
1174
+ _d = !0, _e = err;
1175
+ } finally {
1176
+ try {
1177
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
1178
+ } finally {
1179
+ if (_d) throw _e;
1180
+ }
1181
+ }
1182
+ return _arr;
1183
+ }
1184
+ }
1185
+ function ownKeys(object, enumerableOnly) {
1186
+ var keys = Object.keys(object);
1187
+ if (Object.getOwnPropertySymbols) {
1188
+ var symbols = Object.getOwnPropertySymbols(object);
1189
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
1190
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1191
+ })), keys.push.apply(keys, symbols);
1192
+ }
1193
+ return keys;
1194
+ }
1195
+ function _objectSpread2(target) {
1196
+ for (var i = 1; i < arguments.length; i++) {
1197
+ var source = null != arguments[i] ? arguments[i] : {};
1198
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
1199
+ _defineProperty(target, key, source[key]);
1200
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
1201
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1202
+ });
1203
+ }
1204
+ return target;
1205
+ }
1181
1206
  function _typeof(obj) {
1182
1207
  "@babel/helpers - typeof";
1183
1208
 
1184
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
1185
- _typeof = function (obj) {
1186
- return typeof obj;
1187
- };
1188
- } else {
1189
- _typeof = function (obj) {
1190
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1191
- };
1192
- }
1193
-
1194
- return _typeof(obj);
1209
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
1210
+ return typeof obj;
1211
+ } : function (obj) {
1212
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1213
+ }, _typeof(obj);
1195
1214
  }
1196
-
1197
1215
  function _wrapRegExp() {
1198
1216
  _wrapRegExp = function (re, groups) {
1199
- return new BabelRegExp(re, undefined, groups);
1217
+ return new BabelRegExp(re, void 0, groups);
1200
1218
  };
1201
-
1202
- var _super = RegExp.prototype;
1203
-
1204
- var _groups = new WeakMap();
1205
-
1219
+ var _super = RegExp.prototype,
1220
+ _groups = new WeakMap();
1206
1221
  function BabelRegExp(re, flags, groups) {
1207
1222
  var _this = new RegExp(re, flags);
1208
-
1209
- _groups.set(_this, groups || _groups.get(re));
1210
-
1211
- return _setPrototypeOf(_this, BabelRegExp.prototype);
1223
+ return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype);
1212
1224
  }
1213
-
1214
- _inherits(BabelRegExp, RegExp);
1215
-
1216
- BabelRegExp.prototype.exec = function (str) {
1225
+ function buildGroups(result, re) {
1226
+ var g = _groups.get(re);
1227
+ return Object.keys(g).reduce(function (groups, name) {
1228
+ var i = g[name];
1229
+ if ("number" == typeof i) groups[name] = result[i];else {
1230
+ for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++;
1231
+ groups[name] = result[i[k]];
1232
+ }
1233
+ return groups;
1234
+ }, Object.create(null));
1235
+ }
1236
+ return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) {
1217
1237
  var result = _super.exec.call(this, str);
1218
-
1219
- if (result) result.groups = buildGroups(result, this);
1238
+ if (result) {
1239
+ result.groups = buildGroups(result, this);
1240
+ var indices = result.indices;
1241
+ indices && (indices.groups = buildGroups(indices, this));
1242
+ }
1220
1243
  return result;
1221
- };
1222
-
1223
- BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
1224
- if (typeof substitution === "string") {
1244
+ }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) {
1245
+ if ("string" == typeof substitution) {
1225
1246
  var groups = _groups.get(this);
1226
-
1227
1247
  return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) {
1228
- return "$" + groups[name];
1248
+ var group = groups[name];
1249
+ return "$" + (Array.isArray(group) ? group.join("$") : group);
1229
1250
  }));
1230
- } else if (typeof substitution === "function") {
1251
+ }
1252
+ if ("function" == typeof substitution) {
1231
1253
  var _this = this;
1232
-
1233
1254
  return _super[Symbol.replace].call(this, str, function () {
1234
1255
  var args = arguments;
1235
-
1236
- if (typeof args[args.length - 1] !== "object") {
1237
- args = [].slice.call(args);
1238
- args.push(buildGroups(args, _this));
1239
- }
1240
-
1241
- return substitution.apply(this, args);
1256
+ return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args);
1242
1257
  });
1243
- } else {
1244
- return _super[Symbol.replace].call(this, str, substitution);
1245
1258
  }
1246
- };
1247
-
1248
- function buildGroups(result, re) {
1249
- var g = _groups.get(re);
1250
-
1251
- return Object.keys(g).reduce(function (groups, name) {
1252
- groups[name] = result[g[name]];
1253
- return groups;
1254
- }, Object.create(null));
1259
+ return _super[Symbol.replace].call(this, str, substitution);
1260
+ }, _wrapRegExp.apply(this, arguments);
1261
+ }
1262
+ function _defineProperty(obj, key, value) {
1263
+ key = _toPropertyKey(key);
1264
+ if (key in obj) {
1265
+ Object.defineProperty(obj, key, {
1266
+ value: value,
1267
+ enumerable: true,
1268
+ configurable: true,
1269
+ writable: true
1270
+ });
1271
+ } else {
1272
+ obj[key] = value;
1255
1273
  }
1256
-
1257
- return _wrapRegExp.apply(this, arguments);
1274
+ return obj;
1258
1275
  }
1259
-
1260
1276
  function _inherits(subClass, superClass) {
1261
1277
  if (typeof superClass !== "function" && superClass !== null) {
1262
1278
  throw new TypeError("Super expression must either be null or a function");
1263
1279
  }
1264
-
1265
1280
  subClass.prototype = Object.create(superClass && superClass.prototype, {
1266
1281
  constructor: {
1267
1282
  value: subClass,
@@ -1269,23 +1284,22 @@
1269
1284
  configurable: true
1270
1285
  }
1271
1286
  });
1287
+ Object.defineProperty(subClass, "prototype", {
1288
+ writable: false
1289
+ });
1272
1290
  if (superClass) _setPrototypeOf(subClass, superClass);
1273
1291
  }
1274
-
1275
1292
  function _setPrototypeOf(o, p) {
1276
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
1293
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
1277
1294
  o.__proto__ = p;
1278
1295
  return o;
1279
1296
  };
1280
-
1281
1297
  return _setPrototypeOf(o, p);
1282
1298
  }
1283
-
1284
1299
  function _isNativeReflectConstruct() {
1285
1300
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1286
1301
  if (Reflect.construct.sham) return false;
1287
1302
  if (typeof Proxy === "function") return true;
1288
-
1289
1303
  try {
1290
1304
  Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
1291
1305
  return true;
@@ -1293,10 +1307,9 @@
1293
1307
  return false;
1294
1308
  }
1295
1309
  }
1296
-
1297
1310
  function _construct(Parent, args, Class) {
1298
1311
  if (_isNativeReflectConstruct()) {
1299
- _construct = Reflect.construct;
1312
+ _construct = Reflect.construct.bind();
1300
1313
  } else {
1301
1314
  _construct = function _construct(Parent, args, Class) {
1302
1315
  var a = [null];
@@ -1307,60 +1320,23 @@
1307
1320
  return instance;
1308
1321
  };
1309
1322
  }
1310
-
1311
1323
  return _construct.apply(null, arguments);
1312
1324
  }
1313
-
1314
1325
  function _slicedToArray(arr, i) {
1315
1326
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
1316
1327
  }
1317
-
1318
1328
  function _toConsumableArray(arr) {
1319
1329
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
1320
1330
  }
1321
-
1322
1331
  function _arrayWithoutHoles(arr) {
1323
1332
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
1324
1333
  }
1325
-
1326
1334
  function _arrayWithHoles(arr) {
1327
1335
  if (Array.isArray(arr)) return arr;
1328
1336
  }
1329
-
1330
1337
  function _iterableToArray(iter) {
1331
1338
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1332
1339
  }
1333
-
1334
- function _iterableToArrayLimit(arr, i) {
1335
- var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
1336
-
1337
- if (_i == null) return;
1338
- var _arr = [];
1339
- var _n = true;
1340
- var _d = false;
1341
-
1342
- var _s, _e;
1343
-
1344
- try {
1345
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
1346
- _arr.push(_s.value);
1347
-
1348
- if (i && _arr.length === i) break;
1349
- }
1350
- } catch (err) {
1351
- _d = true;
1352
- _e = err;
1353
- } finally {
1354
- try {
1355
- if (!_n && _i["return"] != null) _i["return"]();
1356
- } finally {
1357
- if (_d) throw _e;
1358
- }
1359
- }
1360
-
1361
- return _arr;
1362
- }
1363
-
1364
1340
  function _unsupportedIterableToArray(o, minLen) {
1365
1341
  if (!o) return;
1366
1342
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -1369,22 +1345,82 @@
1369
1345
  if (n === "Map" || n === "Set") return Array.from(o);
1370
1346
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1371
1347
  }
1372
-
1373
1348
  function _arrayLikeToArray(arr, len) {
1374
1349
  if (len == null || len > arr.length) len = arr.length;
1375
-
1376
1350
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1377
-
1378
1351
  return arr2;
1379
1352
  }
1380
-
1381
1353
  function _nonIterableSpread() {
1382
1354
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1383
1355
  }
1384
-
1385
1356
  function _nonIterableRest() {
1386
1357
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1387
1358
  }
1359
+ function _createForOfIteratorHelper(o, allowArrayLike) {
1360
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
1361
+ if (!it) {
1362
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
1363
+ if (it) o = it;
1364
+ var i = 0;
1365
+ var F = function () {};
1366
+ return {
1367
+ s: F,
1368
+ n: function () {
1369
+ if (i >= o.length) return {
1370
+ done: true
1371
+ };
1372
+ return {
1373
+ done: false,
1374
+ value: o[i++]
1375
+ };
1376
+ },
1377
+ e: function (e) {
1378
+ throw e;
1379
+ },
1380
+ f: F
1381
+ };
1382
+ }
1383
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1384
+ }
1385
+ var normalCompletion = true,
1386
+ didErr = false,
1387
+ err;
1388
+ return {
1389
+ s: function () {
1390
+ it = it.call(o);
1391
+ },
1392
+ n: function () {
1393
+ var step = it.next();
1394
+ normalCompletion = step.done;
1395
+ return step;
1396
+ },
1397
+ e: function (e) {
1398
+ didErr = true;
1399
+ err = e;
1400
+ },
1401
+ f: function () {
1402
+ try {
1403
+ if (!normalCompletion && it.return != null) it.return();
1404
+ } finally {
1405
+ if (didErr) throw err;
1406
+ }
1407
+ }
1408
+ };
1409
+ }
1410
+ function _toPrimitive(input, hint) {
1411
+ if (typeof input !== "object" || input === null) return input;
1412
+ var prim = input[Symbol.toPrimitive];
1413
+ if (prim !== undefined) {
1414
+ var res = prim.call(input, hint || "default");
1415
+ if (typeof res !== "object") return res;
1416
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1417
+ }
1418
+ return (hint === "string" ? String : Number)(input);
1419
+ }
1420
+ function _toPropertyKey(arg) {
1421
+ var key = _toPrimitive(arg, "string");
1422
+ return typeof key === "symbol" ? key : String(key);
1423
+ }
1388
1424
 
1389
1425
  /**
1390
1426
  * 检测值是否类似Promise对象
@@ -1405,7 +1441,9 @@
1405
1441
  return obj !== null && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
1406
1442
  }
1407
1443
 
1444
+ // 港澳居民来往内地通行证正则
1408
1445
  var regHMCard = /^[hm]{1}([0-9]{10}|[0-9]{8})$/i;
1446
+
1409
1447
  /**
1410
1448
  * 检测值是否为港澳居民来往内地通行证,俗称回乡证或回乡卡。
1411
1449
  *
@@ -1428,15 +1466,17 @@
1428
1466
  * isHMCard('m32031177'); // true
1429
1467
  * isHMCard('M32031177'); // true
1430
1468
  */
1431
-
1432
1469
  function isHMCard(value) {
1433
1470
  var valueStr = normalizeString(value);
1434
1471
  return regHMCard.test(valueStr);
1435
1472
  }
1436
1473
 
1437
- var regTWCard = /^\d{8}$/i; // 一次性短期台胞证
1474
+ // 台湾居民来往大陆通行证正则
1475
+ var regTWCard = /^\d{8}$/i;
1438
1476
 
1477
+ // 一次性短期台胞证
1439
1478
  var singleRegTWCard = /^[\da-z]{10,12}$/i;
1479
+
1440
1480
  /**
1441
1481
  * 检测值是否为台湾居民来往大陆通行证,俗称台胞证。
1442
1482
  *
@@ -1459,21 +1499,19 @@
1459
1499
  * // 宽松模式,支持一次性短期通行证
1460
1500
  * isTWCard('F290299977', { loose: true }); // true
1461
1501
  */
1462
-
1463
1502
  function isTWCard(value) {
1464
1503
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1465
1504
  var _options$loose = options.loose,
1466
- loose = _options$loose === void 0 ? false : _options$loose;
1505
+ loose = _options$loose === void 0 ? false : _options$loose;
1467
1506
  var valueStr = normalizeString(value);
1468
-
1469
1507
  if (regTWCard.test(valueStr)) {
1470
1508
  return true;
1471
1509
  }
1472
-
1473
1510
  return loose ? singleRegTWCard.test(valueStr) : false;
1474
1511
  }
1475
1512
 
1476
1513
  var reg$1 = /^[A-Z]{6}[A-Z\d]{2}(?:[A-Z\d]{3})?$/;
1514
+
1477
1515
  /**
1478
1516
  * 检测值是否为 Swift Code。8位或11位,前6位为大写字母,7-8位为大写字母或数字,9-11位为可选的大写字母或数字。
1479
1517
  *
@@ -1494,34 +1532,56 @@
1494
1532
  * isSwiftCode('ICBKCNBJBJM'); // true
1495
1533
  *
1496
1534
  */
1497
-
1498
1535
  function isSwiftCode(value) {
1499
1536
  var valueStr = normalizeString(value);
1500
1537
  return reg$1.test(valueStr);
1501
1538
  }
1502
1539
 
1503
1540
  // 最大安全数字
1504
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // 最小安全数字
1505
-
1541
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
1542
+ // 最小安全数字
1506
1543
  var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
1507
1544
 
1508
1545
  /**
1509
- * 检查值是否为NaN
1546
+ * 检查值是否为Object
1510
1547
  *
1511
1548
  * @static
1512
- * @alias module:Type.isNaN
1549
+ * @alias module:Type.isObject
1513
1550
  * @since 1.1.0
1514
1551
  * @param {*} value 检查值
1515
- * @returns {boolean} 是否为NaN
1552
+ * @returns {boolean} 是否为Object
1516
1553
  * @example
1517
1554
  *
1518
- * isNaN(NaN)
1555
+ * isObject({})
1519
1556
  * // => true
1520
1557
  *
1521
- * isNaN(1)
1522
- * // => false
1558
+ * isObject([1,2,3])
1559
+ * // => true
1560
+ *
1561
+ * isObject(null)
1562
+ * // => false
1523
1563
  */
1564
+ function isObject(value) {
1565
+ var type = _typeof(value);
1566
+ return value != null && (type === 'object' || type === 'function');
1567
+ }
1524
1568
 
1569
+ /**
1570
+ * 检查值是否为NaN
1571
+ *
1572
+ * @static
1573
+ * @alias module:Type.isNaN
1574
+ * @since 1.1.0
1575
+ * @param {*} value 检查值
1576
+ * @returns {boolean} 是否为NaN
1577
+ * @example
1578
+ *
1579
+ * isNaN(NaN)
1580
+ * // => true
1581
+ *
1582
+ * isNaN(1)
1583
+ * // => false
1584
+ */
1525
1585
  function _isNaN(value) {
1526
1586
  return isType(value, 'Number') && isNaN(value);
1527
1587
  }
@@ -1551,7 +1611,6 @@
1551
1611
  * isNumber('1')
1552
1612
  * // => false
1553
1613
  */
1554
-
1555
1614
  function isNumber(value) {
1556
1615
  return isType(value, 'Number');
1557
1616
  }
@@ -1572,7 +1631,6 @@
1572
1631
  * isSymbol("abc")
1573
1632
  * // => false
1574
1633
  */
1575
-
1576
1634
  function isSymbol(value) {
1577
1635
  return isType(value, 'Symbol');
1578
1636
  }
@@ -1583,17 +1641,16 @@
1583
1641
  * 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
1584
1642
  * 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
1585
1643
  */
1644
+
1586
1645
  /**
1587
1646
  * 将值转换为有效数值
1588
1647
  *
1589
1648
  * @param {*} value 要转换的值
1590
1649
  * @returns {number|string} 有效数值
1591
1650
  */
1592
-
1593
1651
  function transformEffectiveNumber(value) {
1594
1652
  /** @type {string|number|undefined} */
1595
1653
  var ret;
1596
-
1597
1654
  if (isString(value)) {
1598
1655
  ret = value.trim(); // ' 15' ' 15 ' 兼容 Number(string) 处理
1599
1656
 
@@ -1614,24 +1671,24 @@
1614
1671
  } else {
1615
1672
  ret = value;
1616
1673
  }
1617
-
1618
1674
  if (Number.isNaN(ret)) {
1619
1675
  return Number.NaN;
1620
- } // @ts-ignore
1621
-
1676
+ }
1622
1677
 
1678
+ // @ts-ignore
1623
1679
  return ret;
1624
1680
  }
1681
+
1625
1682
  /**
1626
1683
  * 是否为科学计数法数字
1627
1684
  *
1628
1685
  * @param {string} num 检查值
1629
1686
  * @returns {boolean}
1630
1687
  */
1631
-
1632
1688
  function isScientificNumber(num) {
1633
1689
  return /\d+\.?\d*e[\+\-]*\d+/i.test(num);
1634
1690
  }
1691
+
1635
1692
  /**
1636
1693
  * 把错误的数据转正
1637
1694
  *
@@ -1642,71 +1699,67 @@
1642
1699
  *
1643
1700
  * strip(0.09999999999999998)=0.1
1644
1701
  */
1645
-
1646
1702
  function strip(num) {
1647
1703
  var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
1648
1704
  return +parseFloat(num.toPrecision(precision));
1649
1705
  }
1706
+
1650
1707
  /**
1651
1708
  * 计算数字的小数点长度,支持科学记数法
1652
1709
  *
1653
1710
  * @param {number|string} num 输入数
1654
1711
  * @returns {number} 小数点长度
1655
1712
  */
1656
-
1657
1713
  function digitLength(num) {
1658
1714
  // Get digit length of e
1659
1715
  var eSplit = num.toString().split(/e/i);
1660
1716
  var len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0);
1661
1717
  return len > 0 ? len : 0;
1662
1718
  }
1719
+
1663
1720
  /**
1664
1721
  * 把小数转成整数,支持科学计数法。如果是小数则放大成整数
1665
1722
  *
1666
1723
  * @param {number|string} num 输入数
1667
1724
  * @returns {number}
1668
1725
  */
1669
-
1670
1726
  function float2Fixed(num) {
1671
1727
  var strNum = String(num);
1672
-
1673
1728
  if (!isScientificNumber(strNum)) {
1674
1729
  return Number(strNum.replace('.', ''));
1675
1730
  }
1676
-
1677
1731
  var dLen = digitLength(num);
1678
1732
  return dLen > 0 ? strip(+num * Math.pow(10, dLen)) : +num;
1679
1733
  }
1734
+
1680
1735
  /**
1681
1736
  * 检测数字是否越界,如果越界给出提示
1682
1737
  * @param {number} num 输入数
1683
1738
  * @returns
1684
1739
  */
1685
-
1686
1740
  function checkBoundary(num) {
1687
1741
  if (+num > MAX_SAFE_INTEGER || +num < MIN_SAFE_INTEGER) {
1688
1742
  devWarn("".concat(num, " is beyond boundary when transfer to integer, the results may not be accurate"));
1689
1743
  }
1690
1744
  }
1745
+
1691
1746
  /**
1692
1747
  * 去掉左边数字0
1693
1748
  *
1694
1749
  * @param {string} num 数字字符串
1695
1750
  * @returns {string}
1696
1751
  */
1697
-
1698
1752
  function trimLeftZero(num) {
1699
1753
  var reg = /^([+-])?(0+)([0-9\.]+)$/;
1700
1754
  var result = reg.exec(num);
1701
1755
  var sign;
1702
-
1703
1756
  if (result) {
1704
1757
  sign = result[1] || '';
1705
1758
  return sign + (result[3][0] === '.' ? '0' + result[3] : result[3]);
1706
1759
  }
1707
-
1708
1760
  return num;
1709
1761
  }
1762
+
1710
1763
  /**
1711
1764
  * 科学计数法转换成普通数字
1712
1765
  *
@@ -1717,40 +1770,36 @@
1717
1770
  * @param {string | number} num 科学计数法数字
1718
1771
  * @returns {string | number} 转换后的数字字符串
1719
1772
  */
1720
-
1721
1773
  function scientificToNumber(num) {
1722
1774
  var strNum = String(num);
1723
-
1724
1775
  if (!isScientificNumber(strNum)) {
1725
1776
  return num;
1726
1777
  }
1727
- /** @type string */
1728
-
1729
1778
 
1779
+ /** @type string */
1730
1780
  var ret;
1731
1781
  var zero = '0';
1732
1782
  var parts = strNum.toLowerCase().split('e');
1733
1783
  var e = parts.pop(); // 存储指数
1734
1784
  // @ts-ignore
1735
-
1736
1785
  var l = Math.abs(e); // 取绝对值,l-1就是0的个数
1737
1786
  // @ts-ignore
1738
-
1739
1787
  var sign = e / l; //判断正负
1740
-
1741
1788
  var coeff_array = parts[0].split('.'); // 将系数按照小数点拆分
1742
- // 如果是小数
1743
1789
 
1790
+ // 如果是小数
1744
1791
  if (sign === -1) {
1745
1792
  // 整数部分
1746
- var intVal = trimLeftZero(coeff_array[0]); // 整数部分大于科学计数后面部分
1747
- // 如: 10e-1, 10.2e-1
1793
+ var intVal = trimLeftZero(coeff_array[0]);
1748
1794
 
1795
+ // 整数部分大于科学计数后面部分
1796
+ // 如: 10e-1, 10.2e-1
1749
1797
  if (intVal.length > l) {
1750
1798
  var thanLen = intVal.length - l;
1751
1799
  var dec = coeff_array[1] || '';
1752
- ret = intVal.slice(0, thanLen); // 处理 10e-1, 100e-1
1800
+ ret = intVal.slice(0, thanLen);
1753
1801
 
1802
+ // 处理 10e-1, 100e-1
1754
1803
  if (intVal.slice(thanLen) !== '0' || dec) {
1755
1804
  ret += '.' + intVal.slice(thanLen) + dec;
1756
1805
  }
@@ -1761,9 +1810,9 @@
1761
1810
  }
1762
1811
  } else {
1763
1812
  // 小数部分
1764
- var _dec = coeff_array[1] || ''; // 如果是整数,将整数除第一位之外的非零数字计入位数,相应的减少0的个数
1765
-
1813
+ var _dec = coeff_array[1] || '';
1766
1814
 
1815
+ // 如果是整数,将整数除第一位之外的非零数字计入位数,相应的减少0的个数
1767
1816
  if (l - _dec.length < 0) {
1768
1817
  ret = trimLeftZero(coeff_array[0] + _dec.substring(0, l)) + '.' + _dec.substring(l);
1769
1818
  } else {
@@ -1771,11 +1820,11 @@
1771
1820
  ret = coeff_array.join('') + new Array(l - _dec.length + 1).join(zero);
1772
1821
  }
1773
1822
  }
1774
-
1775
1823
  return trimLeftZero(ret);
1776
1824
  }
1777
1825
 
1778
1826
  var reg = /^[+-]?\d*\.?\d*$/;
1827
+
1779
1828
  /**
1780
1829
  * 检查数字或数字字符串
1781
1830
  *
@@ -1783,21 +1832,20 @@
1783
1832
  * @param {string} num
1784
1833
  * @returns 是否为数字
1785
1834
  */
1786
-
1787
1835
  function checkNumber(num) {
1788
1836
  if (!(reg.test(num) || isScientificNumber(num)) || _isNaN(num) || typeof num !== 'number' && typeof num !== 'string' || num === '') {
1789
1837
  devWarn("".concat(num, " invalid parameter."));
1790
1838
  return false;
1791
- } // 数字超限如果不是是字符串,可能有异常
1792
- // 如 1111111111111111111111 // => 1.1111111111111111e+21
1793
-
1839
+ }
1794
1840
 
1841
+ // 数字超限如果不是是字符串,可能有异常
1842
+ // 如 1111111111111111111111 // => 1.1111111111111111e+21
1795
1843
  if (typeof num === 'number') {
1796
1844
  checkBoundary(num);
1797
1845
  }
1798
-
1799
1846
  return true;
1800
1847
  }
1848
+
1801
1849
  /**
1802
1850
  * 格式化整数部分
1803
1851
  *
@@ -1806,22 +1854,18 @@
1806
1854
  * @param {string} thousand 千分位符号
1807
1855
  * @returns 格式化后的值
1808
1856
  */
1809
-
1810
-
1811
1857
  function formatInt(intStr, thousand) {
1812
1858
  var txt = '';
1813
1859
  intStr = trimLeftZero(intStr);
1814
1860
  intStr = intStr[0] === '+' ? intStr.substring(1) : intStr; // 去掉+符号
1815
-
1816
1861
  var negativeSymbol = Number(intStr) < 0 ? '-' : '';
1817
1862
  var reArr = negativeSymbol ? intStr.substring(1).split('').reverse() : intStr.split('').reverse();
1818
-
1819
1863
  for (var i = 0; i < reArr.length; i++) {
1820
1864
  txt += reArr[i] + ((i + 1) % 3 === 0 && i + 1 !== reArr.length ? thousand : '');
1821
1865
  }
1822
-
1823
1866
  return negativeSymbol + txt.split('').reverse().join('');
1824
1867
  }
1868
+
1825
1869
  /**
1826
1870
  * 格式化小数部分,如果使用 toFixed,超大额数字会自动被截断
1827
1871
  *
@@ -1831,25 +1875,21 @@
1831
1875
  * @param {string} decimal 小数点符号
1832
1876
  * @returns 格式化后的值
1833
1877
  */
1834
-
1835
-
1836
1878
  function formatDec(decStr, precision, decimal) {
1837
1879
  if (precision === 0) {
1838
1880
  return '';
1839
1881
  }
1840
-
1841
1882
  var zero = 0;
1842
1883
  var ret = '';
1843
-
1844
1884
  if (decStr && Number(decStr) > 0) {
1845
1885
  var tmpNum = parseFloat('0.' + decStr);
1846
1886
  ret = tmpNum.toFixed(precision).substring(2);
1847
1887
  } else {
1848
1888
  ret = zero.toFixed(precision).substring(2);
1849
1889
  }
1850
-
1851
1890
  return decimal + ret;
1852
1891
  }
1892
+
1853
1893
  /**
1854
1894
  * 格式化金额
1855
1895
  *
@@ -1887,43 +1927,42 @@
1887
1927
  * formatMoney(1000.00, { decimal: '&' }); // 1,000&00
1888
1928
  *
1889
1929
  */
1890
-
1891
-
1892
1930
  var formatMoney = function formatMoney(num) {
1893
1931
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1894
1932
  var _options$precision = options.precision,
1895
- precision = _options$precision === void 0 ? 2 : _options$precision,
1896
- symbol = options.symbol,
1897
- _options$thousand = options.thousand,
1898
- thousand = _options$thousand === void 0 ? ',' : _options$thousand,
1899
- _options$decimal = options.decimal,
1900
- decimal = _options$decimal === void 0 ? '.' : _options$decimal; // 数字参数不正确,返回空字符串
1933
+ precision = _options$precision === void 0 ? 2 : _options$precision,
1934
+ symbol = options.symbol,
1935
+ _options$thousand = options.thousand,
1936
+ thousand = _options$thousand === void 0 ? ',' : _options$thousand,
1937
+ _options$decimal = options.decimal,
1938
+ decimal = _options$decimal === void 0 ? '.' : _options$decimal;
1939
+
1940
+ // 数字参数不正确,返回空字符串
1901
1941
  // @ts-ignore
1902
-
1903
1942
  if (!checkNumber(num)) {
1904
1943
  return '';
1905
- } // 参数规整化
1906
-
1944
+ }
1907
1945
 
1946
+ // 参数规整化
1908
1947
  if (typeof precision !== 'number' || _isNaN(precision) || precision < 0) {
1909
1948
  precision = 2;
1910
1949
  } else if (precision > 10) {
1911
1950
  precision = 10;
1912
1951
  }
1913
-
1914
1952
  symbol = typeof symbol === 'string' ? symbol : '';
1915
1953
  thousand = typeof thousand === 'string' ? thousand : ',';
1916
- decimal = typeof decimal === 'string' ? decimal : '.'; // 转换数字字符串,支持科学记数法
1917
-
1918
- var strNum = scientificToNumber(num) + ''; // 整数和小数部分
1954
+ decimal = typeof decimal === 'string' ? decimal : '.';
1919
1955
 
1956
+ // 转换数字字符串,支持科学记数法
1957
+ var strNum = scientificToNumber(num) + '';
1958
+ // 整数和小数部分
1920
1959
  var _strNum$split = strNum.split('.'),
1921
- _strNum$split2 = _slicedToArray(_strNum$split, 2),
1922
- intStr = _strNum$split2[0],
1923
- decStr = _strNum$split2[1];
1924
-
1960
+ _strNum$split2 = _slicedToArray(_strNum$split, 2),
1961
+ intStr = _strNum$split2[0],
1962
+ decStr = _strNum$split2[1];
1925
1963
  return symbol + formatInt(intStr, thousand) + formatDec(decStr, precision, decimal);
1926
1964
  };
1965
+ var formatMoney$1 = formatMoney;
1927
1966
 
1928
1967
  /**
1929
1968
  * 格式化银行卡号
@@ -1933,7 +1972,7 @@
1933
1972
  * @since 1.1.0
1934
1973
  * @param {string} bankCardNo 要处理的字符串
1935
1974
  * @param {Object} [options] 配置项
1936
- * @param {string} [options.char=" "] 间隔字符
1975
+ * @param {string} [options.spaceMark=' '] 间隔字符
1937
1976
  * @param {number} [options.length=4] 间隔长度
1938
1977
  * @returns {string} 格式化的银行卡号
1939
1978
  * @example
@@ -1948,23 +1987,23 @@
1948
1987
  * formatBankCard('6228********890'); // 6228 **** **** 890
1949
1988
  *
1950
1989
  * // 16位银行卡,"-"间隔
1951
- * formatBankCard('6228480402564890', {char: '-'}); // 6228-4804-0256-4890
1990
+ * formatBankCard('6228480402564890', {spaceMark: '-'}); // 6228-4804-0256-4890
1952
1991
  *
1953
1992
  */
1954
-
1955
1993
  function formatBankCard() {
1956
1994
  var bankCardNo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1957
1995
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1958
-
1996
+ // @ts-ignore
1997
+ // TODO 下个版本废弃 char
1959
1998
  var _options$char = options["char"],
1960
- _char = _options$char === void 0 ? ' ' : _options$char,
1961
- _options$length = options.length,
1962
- length = _options$length === void 0 ? 4 : _options$length;
1963
-
1999
+ _char = _options$char === void 0 ? ' ' : _options$char,
2000
+ _options$length = options.length,
2001
+ length = _options$length === void 0 ? 4 : _options$length;
2002
+ var realSpaceMark = 'spaceMark' in options ? options.spaceMark : _char;
1964
2003
  var reg = new RegExp("(.{".concat(length, "})"), 'g');
1965
- var regChar = new RegExp("".concat(_char), 'g');
2004
+ var regChar = new RegExp("".concat(realSpaceMark), 'g');
1966
2005
  var realValue = normalizeString(bankCardNo).replace(regChar, '');
1967
- var str = realValue.replace(reg, "$1".concat(_char));
2006
+ var str = realValue.replace(reg, "$1".concat(realSpaceMark));
1968
2007
  return realValue.length % length === 0 ? str.substring(0, str.length - 1) : str;
1969
2008
  }
1970
2009
 
@@ -2006,35 +2045,31 @@
2006
2045
  * replaceChar('林某某某', {start: 1, end: Infinity, repeat: 2}); // 林**
2007
2046
  *
2008
2047
  */
2009
-
2010
2048
  function replaceChar(str) {
2011
2049
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2012
-
2013
2050
  var _options$char = options["char"],
2014
- _char = _options$char === void 0 ? '*' : _options$char,
2015
- exclude = options.exclude;
2016
-
2051
+ _char = _options$char === void 0 ? '*' : _options$char,
2052
+ exclude = options.exclude;
2017
2053
  var _options$start = options.start,
2018
- start = _options$start === void 0 ? 3 : _options$start,
2019
- _options$end = options.end,
2020
- end = _options$end === void 0 ? -4 : _options$end,
2021
- repeat = options.repeat;
2054
+ start = _options$start === void 0 ? 3 : _options$start,
2055
+ _options$end = options.end,
2056
+ end = _options$end === void 0 ? -4 : _options$end,
2057
+ repeat = options.repeat;
2022
2058
  var realStr = normalizeString(str);
2023
- var strLen = realStr.length; // 开始位置超过str长度
2059
+ var strLen = realStr.length;
2024
2060
 
2061
+ // 开始位置超过str长度
2025
2062
  if (Math.abs(start) >= strLen) {
2026
2063
  return realStr;
2027
2064
  }
2028
-
2029
2065
  start = start >= 0 ? start : strLen + start;
2030
- end = end >= 0 ? end : strLen + end; // 开始位置大于结束位置
2066
+ end = end >= 0 ? end : strLen + end;
2031
2067
 
2068
+ // 开始位置大于结束位置
2032
2069
  if (start >= end) {
2033
2070
  return realStr;
2034
2071
  }
2035
-
2036
2072
  var middleStr = realStr.substring(start, end);
2037
-
2038
2073
  if (exclude) {
2039
2074
  var reg = new RegExp("[^".concat(exclude, "]"), 'g');
2040
2075
  middleStr = middleStr.replace(reg, _char);
@@ -2042,34 +2077,37 @@
2042
2077
  repeat = typeof repeat === 'number' && repeat >= 0 ? repeat : middleStr.length;
2043
2078
  middleStr = _char.repeat(repeat);
2044
2079
  }
2045
-
2046
2080
  return realStr.substring(0, start) + middleStr + realStr.substring(end);
2047
2081
  }
2048
2082
 
2083
+ // 简体
2049
2084
  var chnNumberChar = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
2050
- var chnUnitChar = ['', '十', '百', '千']; // 繁体
2085
+ var chnUnitChar = ['', '十', '百', '千'];
2051
2086
 
2087
+ // 繁体
2052
2088
  var big5NumberChar = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
2053
- var big5UnitChar = ['', '拾', '佰', '仟']; // 数字字符、计数单位
2089
+ var big5UnitChar = ['', '拾', '佰', '仟'];
2090
+
2091
+ // 数字字符、计数单位
2054
2092
 
2055
2093
  /**
2056
2094
  * @type {string[]}
2057
2095
  * @private
2058
2096
  */
2059
-
2060
2097
  var numberChar;
2098
+
2061
2099
  /**
2062
2100
  * @type {string[]}
2063
2101
  * @private
2064
2102
  */
2065
-
2066
2103
  var unitChar;
2104
+
2067
2105
  /**
2068
2106
  * @type {string[]}
2069
2107
  * @private
2070
2108
  */
2071
-
2072
2109
  var unitSection;
2110
+
2073
2111
  /**
2074
2112
  * 每个小节的内部进行转化
2075
2113
  *
@@ -2077,18 +2115,16 @@
2077
2115
  * @param {number} section 数字
2078
2116
  * @returns {string} 转化的数字
2079
2117
  */
2080
-
2081
2118
  function sectionToChinese(section) {
2082
2119
  var str = '';
2083
2120
  var chnstr = '';
2084
2121
  var zero = false; //zero为是否进行补零, 第一次进行取余由于为个位数,默认不补零
2085
-
2086
2122
  var unitPos = 0;
2087
-
2088
2123
  while (section > 0) {
2089
2124
  // 对数字取余10,得到的数即为个位数
2090
- var v = section % 10; //如果数字为零,则对字符串进行补零
2125
+ var v = section % 10;
2091
2126
 
2127
+ //如果数字为零,则对字符串进行补零
2092
2128
  if (v == 0) {
2093
2129
  if (zero) {
2094
2130
  //如果遇到连续多次取余都是0,那么只需补一个零即可
@@ -2102,13 +2138,12 @@
2102
2138
  str += unitChar[unitPos];
2103
2139
  chnstr = str + chnstr;
2104
2140
  }
2105
-
2106
2141
  unitPos++;
2107
2142
  section = Math.floor(section / 10);
2108
2143
  }
2109
-
2110
2144
  return chnstr;
2111
2145
  }
2146
+
2112
2147
  /**
2113
2148
  * 转换整数
2114
2149
  *
@@ -2116,26 +2151,20 @@
2116
2151
  * @param {number} num 要转换的数字
2117
2152
  * @returns {string} 中文数字
2118
2153
  */
2119
-
2120
-
2121
2154
  function convertInteger(num) {
2122
2155
  var numInt = Math.floor(num);
2123
2156
  var unitPos = 0;
2124
2157
  var strIns = '';
2125
2158
  var chnStr = '';
2126
2159
  var needZero = false;
2127
-
2128
2160
  if (numInt === 0) {
2129
2161
  return numberChar[0];
2130
2162
  }
2131
-
2132
2163
  while (numInt > 0) {
2133
2164
  var section = numInt % 10000;
2134
-
2135
2165
  if (needZero) {
2136
2166
  chnStr = numberChar[0] + chnStr;
2137
2167
  }
2138
-
2139
2168
  strIns = sectionToChinese(section);
2140
2169
  strIns += section !== 0 ? unitSection[unitPos] : unitSection[0];
2141
2170
  chnStr = strIns + chnStr;
@@ -2143,29 +2172,26 @@
2143
2172
  numInt = Math.floor(numInt / 10000);
2144
2173
  unitPos++;
2145
2174
  }
2146
-
2147
2175
  return chnStr;
2148
2176
  }
2177
+
2149
2178
  /**
2150
2179
  * 转换小数
2151
2180
  *
2152
2181
  * @private
2153
2182
  * @param {number} num 要转换的数字
2154
2183
  */
2155
-
2156
-
2157
2184
  function convertDecimal(num) {
2158
2185
  var strNum = num + '';
2159
2186
  var index = strNum.indexOf('.');
2160
2187
  var ret = '';
2161
-
2162
2188
  if (index > -1) {
2163
2189
  var decimalStr = strNum.slice(index + 1);
2164
2190
  ret = mapNumberChar(parseInt(decimalStr));
2165
2191
  }
2166
-
2167
2192
  return ret;
2168
2193
  }
2194
+
2169
2195
  /**
2170
2196
  * 映射为中文数字
2171
2197
  *
@@ -2173,18 +2199,15 @@
2173
2199
  * @param {number} num 要处理的数字
2174
2200
  * @returns {string} 返回中文数字的映射
2175
2201
  */
2176
-
2177
-
2178
2202
  function mapNumberChar(num) {
2179
2203
  var strNum = num + '';
2180
2204
  var ret = '';
2181
-
2182
2205
  for (var i = 0, len = strNum.length; i < len; i++) {
2183
2206
  ret += numberChar[parseInt(strNum[i])];
2184
2207
  }
2185
-
2186
2208
  return ret;
2187
2209
  }
2210
+
2188
2211
  /**
2189
2212
  * 数字转中文数字
2190
2213
  * 不在安全数字 -9007199254740991~9007199254740991 内,处理会有异常
@@ -2222,31 +2245,31 @@
2222
2245
  * numberToChinese(1990, {unit: false, zero:'〇'}); // 一九九〇
2223
2246
  *
2224
2247
  */
2225
-
2226
-
2227
2248
  function numberToChinese(num) {
2228
2249
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2229
2250
  var _options$big = options.big5,
2230
- big5 = _options$big === void 0 ? false : _options$big,
2231
- _options$unit = options.unit,
2232
- unit = _options$unit === void 0 ? true : _options$unit,
2233
- _options$zero = options.zero,
2234
- zero = _options$zero === void 0 ? '' : _options$zero,
2235
- _options$negative = options.negative,
2236
- negative = _options$negative === void 0 ? '负' : _options$negative,
2237
- _options$unitConfig = options.unitConfig,
2238
- unitConfig = _options$unitConfig === void 0 ? {} : _options$unitConfig;
2251
+ big5 = _options$big === void 0 ? false : _options$big,
2252
+ _options$unit = options.unit,
2253
+ unit = _options$unit === void 0 ? true : _options$unit,
2254
+ _options$zero = options.zero,
2255
+ zero = _options$zero === void 0 ? '' : _options$zero,
2256
+ _options$negative = options.negative,
2257
+ negative = _options$negative === void 0 ? '负' : _options$negative,
2258
+ _options$unitConfig = options.unitConfig,
2259
+ unitConfig = _options$unitConfig === void 0 ? {} : _options$unitConfig;
2239
2260
  var _options$decimal = options.decimal,
2240
- decimal = _options$decimal === void 0 ? '' : _options$decimal; // 非数字 或 NaN 不处理
2261
+ decimal = _options$decimal === void 0 ? '' : _options$decimal;
2241
2262
 
2263
+ // 非数字 或 NaN 不处理
2242
2264
  if (typeof num !== 'number' || isNaN(num)) {
2243
2265
  devWarn("\u53C2\u6570\u9519\u8BEF ".concat(num, "\uFF0C\u8BF7\u4F20\u5165\u6570\u5B57"));
2244
2266
  return '';
2245
- } // 超过安全数字提示
2246
-
2267
+ }
2247
2268
 
2248
- checkBoundary(num); // 设置数字字符和计数单位
2269
+ // 超过安全数字提示
2270
+ checkBoundary(num);
2249
2271
 
2272
+ // 设置数字字符和计数单位
2250
2273
  if (big5) {
2251
2274
  numberChar = big5NumberChar.slice();
2252
2275
  unitChar = big5UnitChar.slice();
@@ -2255,31 +2278,34 @@
2255
2278
  numberChar = chnNumberChar.slice();
2256
2279
  unitChar = chnUnitChar.slice();
2257
2280
  decimal = decimal || '点';
2258
- } // 设置节点计数单位,万、亿、万亿
2259
-
2281
+ }
2260
2282
 
2283
+ // 设置节点计数单位,万、亿、万亿
2261
2284
  var unitWan = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.w) || '万';
2262
2285
  var unitYi = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.y) || '亿';
2263
2286
  var unitWanYi = unitWan + unitYi;
2264
- unitSection = ['', unitWan, unitYi, unitWanYi]; // 设置0
2287
+ unitSection = ['', unitWan, unitYi, unitWanYi];
2265
2288
 
2289
+ // 设置0
2266
2290
  if (zero) {
2267
2291
  numberChar[0] = zero;
2268
- } // 前置字符,负数处理
2269
-
2292
+ }
2270
2293
 
2271
- var preStr = num < 0 ? negative : ''; // 整数和小数
2294
+ // 前置字符,负数处理
2295
+ var preStr = num < 0 ? negative : '';
2272
2296
 
2297
+ // 整数和小数
2273
2298
  var chnInteger, chnDecimal;
2274
- var numAbs = Math.abs(num); // 处理整数
2299
+ var numAbs = Math.abs(num);
2275
2300
 
2301
+ // 处理整数
2276
2302
  if (unit) {
2277
2303
  chnInteger = convertInteger(numAbs);
2278
2304
  } else {
2279
2305
  chnInteger = mapNumberChar(Math.floor(numAbs));
2280
- } // 处理小数
2281
-
2306
+ }
2282
2307
 
2308
+ // 处理小数
2283
2309
  chnDecimal = convertDecimal(numAbs);
2284
2310
  return chnDecimal ? "".concat(preStr).concat(chnInteger).concat(decimal).concat(chnDecimal) : "".concat(preStr).concat(chnInteger);
2285
2311
  }
@@ -2291,6 +2317,8 @@
2291
2317
  * @alias module:Processor.bytesToSize
2292
2318
  * @since 3.8.0
2293
2319
  * @param {number} bytes 字节大小
2320
+ * @param {Object} [options] 配置项
2321
+ * @param {string} [options.spaceMark=' '] 间隔字符
2294
2322
  * @returns {string} 存储单位值
2295
2323
  * @example
2296
2324
  *
@@ -2299,18 +2327,25 @@
2299
2327
  * bytesToSize(3.213243*1024*1024); // 3.21 MB
2300
2328
  * bytesToSize(1024*1024*1024); // 1 GB
2301
2329
  *
2330
+ * // 自定义间隔符号
2331
+ * bytesToSize(0, { spaceMark: '' }); // 0B
2332
+ * bytesToSize(1024, { spaceMark: '' }); // 1KB
2333
+ *
2302
2334
  */
2303
2335
  function bytesToSize(bytes) {
2336
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2337
+ var _options$spaceMark = options.spaceMark,
2338
+ spaceMark = _options$spaceMark === void 0 ? ' ' : _options$spaceMark;
2304
2339
  var numBytes = typeof bytes !== 'number' ? Number(bytes) : bytes;
2305
- if (numBytes === 0 || isNaN(numBytes)) return '0 B';
2306
- var k = 1024; // 存储单位
2307
-
2340
+ if (numBytes === 0 || isNaN(numBytes)) return "0".concat(spaceMark, "B");
2341
+ var k = 1024;
2342
+ // 存储单位
2308
2343
  var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
2309
2344
  var i = Math.floor(Math.log(numBytes) / Math.log(k));
2310
- return sizes[i] ? "".concat(Number((numBytes / Math.pow(k, i)).toFixed(2)), " ").concat(sizes[i]) : numBytes + '';
2345
+ return sizes[i] ? "".concat(Number((numBytes / Math.pow(k, i)).toFixed(2))).concat(spaceMark).concat(sizes[i]) : numBytes + '';
2311
2346
  }
2312
2347
 
2313
- var regIdCard = /*#__PURE__*/_wrapRegExp(/^([0-9]{2})([0-9]{2})([0-9]{2})((?:[0-9]{2})?[0-9]{2})([0-9]{2})([0-9]{2})[0-9]{2}([0-9])(?:[0-9]|X)?$/i, {
2348
+ var regIdCard = /*#__PURE__*/_wrapRegExp(/^(\d{2})(\d{2})(\d{2})((?:\d{2})?\d{2})(\d{2})(\d{2})\d{2}(\d)(?:\d|X)?$/i, {
2314
2349
  province: 1,
2315
2350
  city: 2,
2316
2351
  area: 3,
@@ -2319,18 +2354,28 @@
2319
2354
  day: 6,
2320
2355
  gender: 7
2321
2356
  });
2322
-
2323
- var Provinces = [// 华北地区:北京市|110000,天津市|120000,河北省|130000,山西省|140000,内蒙古自治区|150000
2324
- ['11', '北京市'], ['12', '天津市'], ['13', '河北省'], ['14', '山西省'], ['15', '内蒙古自治区'], // 东北地区: 辽宁省|210000,吉林省|220000,黑龙江省|230000
2325
- ['21', '辽宁省'], ['22', '吉林省'], ['23', '黑龙江省'], // 华东地区: 上海市|310000,江苏省|320000,浙江省|330000,安徽省|340000,福建省|350000,江西省|360000,山东省|370000
2326
- ['31', '上海市'], ['32', '江苏省'], ['33', '浙江省'], ['34', '安徽省'], ['35', '福建省'], ['36', '江西省'], ['37', '山东省'], // 华中地区: 河南省|410000,湖北省|420000,湖南省|430000
2327
- ['41', '河南省'], ['42', '湖北省'], ['43', '湖南省'], // 华南地区:广东省|440000,广西壮族自治区|450000,海南省|460000
2328
- ['44', '广东省'], ['45', '广西壮族自治区'], ['46', '海南省'], // 西南地区:重庆市|500000,四川省|510000,贵州省|520000,云南省|530000,西藏自治区|540000
2329
- ['50', '重庆市'], ['51', '四川省'], ['52', '贵州省'], ['53', '云南省'], ['54', '西藏自治区'], // 西北地区: 陕西省|610000,甘肃省|620000,青海省|630000,宁夏回族自治区|640000,新疆维吾尔自治区|650000
2330
- ['61', '陕西省'], ['62', '甘肃省'], ['63', '青海省'], ['64', '宁夏回族自治区'], ['65', '新疆维吾尔自治区'], // 台湾地区:台湾省|710000
2357
+ var Provinces = [
2358
+ // 华北地区:北京市|110000,天津市|120000,河北省|130000,山西省|140000,内蒙古自治区|150000
2359
+ ['11', '北京市'], ['12', '天津市'], ['13', '河北省'], ['14', '山西省'], ['15', '内蒙古自治区'],
2360
+ // 东北地区: 辽宁省|210000,吉林省|220000,黑龙江省|230000
2361
+ ['21', '辽宁省'], ['22', '吉林省'], ['23', '黑龙江省'],
2362
+ // 华东地区: 上海市|310000,江苏省|320000,浙江省|330000,安徽省|340000,福建省|350000,江西省|360000,山东省|370000
2363
+ ['31', '上海市'], ['32', '江苏省'], ['33', '浙江省'], ['34', '安徽省'], ['35', '福建省'], ['36', '江西省'], ['37', '山东省'],
2364
+ // 华中地区: 河南省|410000,湖北省|420000,湖南省|430000
2365
+ ['41', '河南省'], ['42', '湖北省'], ['43', '湖南省'],
2366
+ // 华南地区:广东省|440000,广西壮族自治区|450000,海南省|460000
2367
+ ['44', '广东省'], ['45', '广西壮族自治区'], ['46', '海南省'],
2368
+ // 西南地区:重庆市|500000,四川省|510000,贵州省|520000,云南省|530000,西藏自治区|540000
2369
+ ['50', '重庆市'], ['51', '四川省'], ['52', '贵州省'], ['53', '云南省'], ['54', '西藏自治区'],
2370
+ // 西北地区: 陕西省|610000,甘肃省|620000,青海省|630000,宁夏回族自治区|640000,新疆维吾尔自治区|650000
2371
+ ['61', '陕西省'], ['62', '甘肃省'], ['63', '青海省'], ['64', '宁夏回族自治区'], ['65', '新疆维吾尔自治区'],
2372
+ // 台湾地区:台湾省|710000
2331
2373
  // 台湾居民公民身份号码地址码为830000,参考 http://www.wanweibaike.com/wiki-中华人民共和国行政区划代码_(7区)、https://zh.wikipedia.org/wiki/港澳台居民居住证
2332
- ['71', '台湾省'], ['83', '台湾省'], // 港澳地区:香港特别行政区|810000,澳门特别行政区|820000
2333
- ['81', '香港特别行政区'], ['82', '澳门特别行政区']]; // 第一位数字是以前的大区制代码。第二位是大区所在省市编码。全国共分为8个大区:华北(1)、东北(2)、华东(3)、中南(4)、西南(5)、西北(6)、台湾(7)和港澳(8)。
2374
+ ['71', '台湾省'], ['83', '台湾省'],
2375
+ // 港澳地区:香港特别行政区|810000,澳门特别行政区|820000
2376
+ ['81', '香港特别行政区'], ['82', '澳门特别行政区']];
2377
+
2378
+ // 第一位数字是以前的大区制代码。第二位是大区所在省市编码。全国共分为8个大区:华北(1)、东北(2)、华东(3)、中南(4)、西南(5)、西北(6)、台湾(7)和港澳(8)。
2334
2379
  // const Regions = [
2335
2380
  // ['1', '华北地区'],
2336
2381
  // ['2', '东北地区'],
@@ -2395,19 +2440,17 @@
2395
2440
  * }
2396
2441
  *
2397
2442
  */
2398
-
2399
2443
  function parseIdCard(id) {
2400
2444
  if (!regIdCard.test(id)) {
2401
2445
  return null;
2402
2446
  }
2447
+
2403
2448
  /** @type {RegExpExecArray} */
2404
2449
  // @ts-ignore
2405
-
2406
-
2407
2450
  var info = regIdCard.exec(id);
2451
+
2408
2452
  /** @type {{ province: string, city: string, area: string, year: string, month: string, day: string, gender: string }} */
2409
2453
  // @ts-ignore
2410
-
2411
2454
  var origin = (info === null || info === void 0 ? void 0 : info.groups) || {
2412
2455
  province: info[1],
2413
2456
  city: info[2],
@@ -2420,13 +2463,12 @@
2420
2463
  var province = Provinces.find(function (item) {
2421
2464
  return item[0] === origin.province;
2422
2465
  });
2423
-
2424
2466
  if (!province) {
2425
2467
  return null;
2426
2468
  }
2427
-
2428
2469
  var birthday = "".concat(origin.year, "-").concat(origin.month, "-").concat(origin.day);
2429
- var gender = Number(origin.gender) % 2 === 0 ? '女' : '男'; // const region = Regions.find(item => item[0] === origin.province?.substring(0, 1));
2470
+ var gender = Number(origin.gender) % 2 === 0 ? '女' : '男';
2471
+ // const region = Regions.find(item => item[0] === origin.province?.substring(0, 1));
2430
2472
 
2431
2473
  return {
2432
2474
  // region,
@@ -2467,12 +2509,11 @@
2467
2509
  function blobToDataURL(blob) {
2468
2510
  return new Promise(function (resolve, reject) {
2469
2511
  var reader = new FileReader();
2470
- reader.readAsDataURL(blob); // @ts-ignore
2471
-
2512
+ reader.readAsDataURL(blob);
2513
+ // @ts-ignore
2472
2514
  reader.onload = function () {
2473
2515
  return resolve(reader.result);
2474
2516
  };
2475
-
2476
2517
  reader.onerror = function (error) {
2477
2518
  return reject(error);
2478
2519
  };
@@ -2493,17 +2534,15 @@
2493
2534
  * dataURLToBlob(dataurl); // Blob {size: 32, type: 'text/html'}
2494
2535
  */
2495
2536
  function dataURLToBlob(dataurl) {
2496
- var arr = dataurl.split(','); // @ts-ignore
2497
-
2537
+ var arr = dataurl.split(',');
2538
+ // @ts-ignore
2498
2539
  var mime = arr[0].match(/:(.*?);/)[1];
2499
2540
  var bstr = atob(arr[1]);
2500
2541
  var n = bstr.length;
2501
2542
  var u8arr = new Uint8Array(n);
2502
-
2503
2543
  while (n--) {
2504
2544
  u8arr[n] = bstr.charCodeAt(n);
2505
2545
  }
2506
-
2507
2546
  return new Blob([u8arr], {
2508
2547
  type: mime
2509
2548
  });
@@ -2539,6 +2578,8 @@
2539
2578
  return "data:".concat(mimetype).concat(base64 ? ';base64' : '', ",").concat(data);
2540
2579
  }
2541
2580
 
2581
+ // TODO: 函数重载,类型参照 Date
2582
+
2542
2583
  /**
2543
2584
  * 创建一个 Date 实例日期对象,同 new Date() 。<br/>
2544
2585
  * 规避了苹果设备浏览器不支持部分格式(YYYY-MM-DD HH-mm 或 YYYY.MM.DD)。
@@ -2561,20 +2602,17 @@
2561
2602
  *
2562
2603
  *
2563
2604
  */
2564
-
2565
2605
  function safeDate(value) {
2566
2606
  var safeValue = typeof value === 'string' ? value.replace(/[\\.-]/g, '/') : value;
2567
-
2568
2607
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2569
2608
  args[_key - 1] = arguments[_key];
2570
2609
  }
2571
-
2572
2610
  if (args && args.length > 0) {
2573
2611
  // @ts-ignore
2574
2612
  return _construct(Date, [safeValue].concat(args));
2575
- } // @ts-ignore
2576
-
2613
+ }
2577
2614
 
2615
+ // @ts-ignore
2578
2616
  return isNil(safeValue) ? new Date() : new Date(safeValue);
2579
2617
  }
2580
2618
 
@@ -2586,16 +2624,16 @@
2586
2624
  * @since 4.5.0
2587
2625
  * @param {string} mobileNo 手机号码
2588
2626
  * @param {object} [options] 配置项
2589
- * @param {string} [options.char=' '] 间隔字符
2627
+ * @param {string} [options.spaceMark=' '] 间隔字符
2590
2628
  * @returns {string} 格式化后的手机号码
2591
2629
  * @example
2592
2630
  *
2593
2631
  * formatMobile('13345678900'); // 133 4567 8900
2594
- * formatMobile('13345678900', { char: '-' }); // 133-4567-8900
2632
+ * formatMobile('13345678900', { spaceMark: '-' }); // 133-4567-8900
2595
2633
  *
2596
2634
  * // 脱敏手机号码
2597
2635
  * formatMobile('133****1234'); // 133 **** 1234
2598
- * formatMobile('133****1234', { char: '-' }); // 133-****-1234
2636
+ * formatMobile('133****1234', { spaceMark: '-' }); // 133-****-1234
2599
2637
  *
2600
2638
  * // 手机号码位数不够
2601
2639
  * formatMobile('133'); // 133
@@ -2603,24 +2641,21 @@
2603
2641
  * formatMobile('13345678'); // 133 4567 8
2604
2642
  *
2605
2643
  */
2606
-
2607
2644
  function formatMobile(mobileNo) {
2608
2645
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2609
-
2646
+ // @ts-ignore
2647
+ // TODO 下个版本废弃 char
2610
2648
  var _options$char = options["char"],
2611
- _char = _options$char === void 0 ? ' ' : _options$char;
2612
-
2613
- var regChar = new RegExp(_char, 'g');
2649
+ _char = _options$char === void 0 ? ' ' : _options$char;
2650
+ var realSpaceMark = 'spaceMark' in options ? options.spaceMark : _char;
2651
+ var regChar = new RegExp(realSpaceMark, 'g');
2614
2652
  var realValue = normalizeString(mobileNo).replace(regChar, '').substring(0, 11);
2615
-
2616
2653
  if (realValue.length > 7) {
2617
- return realValue.replace(/^(...)(....)/g, "$1".concat(_char, "$2").concat(_char));
2654
+ return realValue.replace(/^(...)(....)/g, "$1".concat(realSpaceMark, "$2").concat(realSpaceMark));
2618
2655
  }
2619
-
2620
2656
  if (realValue.length > 3) {
2621
- return realValue.replace(/^(...)/g, "$1".concat(_char));
2657
+ return realValue.replace(/^(...)/g, "$1".concat(realSpaceMark));
2622
2658
  }
2623
-
2624
2659
  return realValue;
2625
2660
  }
2626
2661
 
@@ -2647,23 +2682,411 @@
2647
2682
  * padZero('688', 5); // 00688
2648
2683
  *
2649
2684
  */
2650
-
2651
2685
  function padZero(value) {
2652
2686
  var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
2653
2687
  var str = normalizeString(value);
2654
2688
  var len = str.length;
2655
-
2656
2689
  if (typeof size !== 'number' || size < 0) {
2657
2690
  size = 0;
2658
2691
  }
2659
-
2660
2692
  if (len < size) {
2661
2693
  return '0'.repeat(size - len) + str;
2662
2694
  }
2663
-
2664
2695
  return str;
2665
2696
  }
2666
2697
 
2698
+ /**
2699
+ * 转换字段名,返回一个转换字段后的值,不改变原值。
2700
+ *
2701
+ * @static
2702
+ * @alias module:Processor.transformFieldNames
2703
+ * @since 4.14.0
2704
+ * @template {*} D
2705
+ * @template {Record<string, keyof D>} F
2706
+ * @template {string} C
2707
+ * @param {D[]} data 对象数组。如果是树结构数据,需要指定第三个参数 childrenFieldName
2708
+ * @param {F} fieldNames 字段名映射
2709
+ * @param {C} [childrenFieldName] 子级数据字段名
2710
+ * @returns {import('./transformFieldNames.type.js').TransformFieldNames<D, F, C>}
2711
+ * @example
2712
+ *
2713
+ * const options = [{code: '1', name: 'one'},{code:'2', name:'two'}];
2714
+ * const newOptions = transformFieldNames(options, {label: 'name', value: 'code'});
2715
+ * // [{value: '1', label: 'one'},{value:'2', label:'two'}]
2716
+ *
2717
+ * // 嵌套数据,指定子级字段名 children
2718
+ * const options2 = [{code: '1', name: 'one'},{code:'2', name:'two', children: [{code:'2-1', name:'two-one', children: [{code: '2-1-1', name:'two-one-one'}]}]}];
2719
+ * const newOptions2 = transformFieldNames(options2, {label: 'name', value: 'code'}, 'children');
2720
+ * // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one', children: [{value: '2-1-1', label:'two-one-one'}]}]}]
2721
+ *
2722
+ * const options3 = [{code: '1', name: 'one'},{code:'2', name:'two', childs: [{code:'2-1', name:'two-one'}]}];
2723
+ * const newOptions3 = transformFieldNames(options3, {label: 'name', value: 'code'}, 'childs');
2724
+ * // [{value: '1', label: 'one'},{value:'2', label:'two', childs: [{value: '2-1', label:'two-one'}]}]
2725
+ *
2726
+ * // 嵌套数据,并替换子集字段名
2727
+ * const newOptions4 = transformFieldNames(options3, {label: 'name', value: 'code', children: 'childs'}, 'childs');
2728
+ * // [{value: '1', label: 'one'},{value:'2', label:'two', children: [{value: '2-1', label:'two-one'}]}]
2729
+ */
2730
+ function transformFieldNames(data, fieldNames, childrenFieldName) {
2731
+ if (!Array.isArray(data)) {
2732
+ return data;
2733
+ }
2734
+ if (data.length <= 0) {
2735
+ // @ts-ignore
2736
+ return [];
2737
+ }
2738
+
2739
+ /**
2740
+ * 递归处理字段名
2741
+ *
2742
+ * @param {Array.<object>} arr 列表数据
2743
+ * @returns {*}
2744
+ */
2745
+ function recusion() {
2746
+ var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2747
+ return arr.map(function (item) {
2748
+ if (!isObject(item)) {
2749
+ return item;
2750
+ }
2751
+ var newItem = _objectSpread2({}, item);
2752
+ /** @type {Array.<string>} */
2753
+ var delKeys = [];
2754
+
2755
+ // 树形数据子节点
2756
+ // @ts-ignore
2757
+ if (childrenFieldName && Array.isArray(newItem[childrenFieldName]) && newItem[childrenFieldName].length > 0) {
2758
+ // @ts-ignore
2759
+ newItem[childrenFieldName] = recusion(newItem[childrenFieldName].slice());
2760
+ }
2761
+
2762
+ // 替换字段名
2763
+ Object.keys(fieldNames).forEach(function (newKey) {
2764
+ var oldKey = fieldNames[newKey];
2765
+ if (oldKey in newItem) {
2766
+ // @ts-ignore
2767
+ newItem[newKey] = newItem[oldKey];
2768
+ // @ts-ignore
2769
+ delKeys.push(oldKey);
2770
+ }
2771
+ });
2772
+
2773
+ // 删除旧字段
2774
+ if (delKeys.length > 0) {
2775
+ delKeys.forEach(function (delKey) {
2776
+ // @ts-ignore
2777
+ delete newItem[delKey];
2778
+ });
2779
+ }
2780
+ return newItem;
2781
+ });
2782
+ }
2783
+
2784
+ // @ts-ignore
2785
+ return recusion(data.slice());
2786
+ }
2787
+
2788
+ /**
2789
+ * 递归处理空子级
2790
+ *
2791
+ * @private
2792
+ * @template {Record<string,any>} [T=Record<string,any>]
2793
+ * @param {T[]} arr 列表数据
2794
+ * @param {object} options 配置项
2795
+ * @param {string} [options.childrenField='children'] 子级字段名称
2796
+ * @param {'none'|'null'|'array'} [options.emptyChildrenValue='none'] 子级为空时的值,none表示删除该子级,null表示为null,array表示为[]。
2797
+ */
2798
+ function processEmptyChildren(arr) {
2799
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2800
+ var _options$childrenFiel = options.childrenField,
2801
+ childrenField = _options$childrenFiel === void 0 ? 'children' : _options$childrenFiel,
2802
+ _options$emptyChildre = options.emptyChildrenValue,
2803
+ emptyChildrenValue = _options$emptyChildre === void 0 ? 'none' : _options$emptyChildre;
2804
+ arr.forEach(function (item) {
2805
+ if (isObject(item) && Array.isArray(item[childrenField])) {
2806
+ if (item[childrenField].length <= 0) {
2807
+ if (emptyChildrenValue === 'null') {
2808
+ // @ts-ignore
2809
+ item[childrenField] = null;
2810
+ } else if (emptyChildrenValue === 'none') {
2811
+ delete item[childrenField];
2812
+ }
2813
+ } else {
2814
+ processEmptyChildren(item[childrenField], options);
2815
+ }
2816
+ }
2817
+ });
2818
+ }
2819
+
2820
+ /**
2821
+ * 列表数据转树结构
2822
+ *
2823
+ * @static
2824
+ * @alias module:Processor.listToTree
2825
+ * @since 4.14.0
2826
+ * @template {Record<string,any>} [T=Record<string,any>]
2827
+ * @template {*} [R=T&Record<string,any>]
2828
+ * @param {T[]} list 列表数据
2829
+ * @param {object} options 配置项
2830
+ * @param {string} [options.keyField='id'] 当前数据的键值字段名称
2831
+ * @param {string} [options.parentField='pid'] 当前数据的父级字段名称
2832
+ * @param {string} [options.childrenField='children'] 子级字段名称
2833
+ * @param {'none'|'null'|'array'} [options.emptyChildrenValue='none'] 子级为空时的值,none表示删除该子级,null表示为null,array表示为[]。
2834
+ * @returns {R[]} 树结构
2835
+ * @example
2836
+ *
2837
+ * const menus = [
2838
+ * { id: '1', name: '首页', code: 'trade', pid: null },
2839
+ * { id: '2', name: '交易管理', code: 'trade', pid: null },
2840
+ * { id: '3', name: '交易查询', code: 'trade-1', pid: '2' },
2841
+ * { id: '4', name: '交易查询-查询操作', code: 'trade-1-1', pid: '3' },
2842
+ * { id: '5', name: '权限管理', code: 'authorization', pid: null },
2843
+ * { id: '6', name: '角色管理', code: 'authorization-1', pid: '5' },
2844
+ * { id: '7', name: '用户管理', code: 'authorization-2', pid: '5' }
2845
+ * ];
2846
+ * listToTree(menus);
2847
+ * // [{"id":"1","name":"首页","code":"trade","pid":null},{"id":"2","name":"交易管理","code":"trade","pid":null,"children":[{"id":"3","name":"交易查询","code":"trade-1","pid":"2","children":[{"id":"4","name":"交易查询-查询操作","code":"trade-1-1","pid":"3"}]}]},{"id":"5","name":"权限管理","code":"authorization","pid":null,"children":[{"id":"6","name":"角色管理","code":"authorization-1","pid":"5"},{"id":"7","name":"用户管理","code":"authorization-2","pid":"5"}]}]
2848
+ *
2849
+ * // 自定义子级字段名
2850
+ * listToTree(basicMenus, { childrenField: 'childs' });
2851
+ * // [{"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"}]}]
2852
+ *
2853
+ */
2854
+ function listToTree(list) {
2855
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2856
+ var _options$keyField = options.keyField,
2857
+ keyField = _options$keyField === void 0 ? 'id' : _options$keyField,
2858
+ _options$parentField = options.parentField,
2859
+ parentField = _options$parentField === void 0 ? 'pid' : _options$parentField,
2860
+ _options$childrenFiel2 = options.childrenField,
2861
+ childrenField = _options$childrenFiel2 === void 0 ? 'children' : _options$childrenFiel2,
2862
+ _options$emptyChildre2 = options.emptyChildrenValue,
2863
+ emptyChildrenValue = _options$emptyChildre2 === void 0 ? 'none' : _options$emptyChildre2;
2864
+
2865
+ /** @type {R[]} */
2866
+ var tree = [];
2867
+
2868
+ /** @type {Object.<string, T[]>} */
2869
+ var record = {};
2870
+ list.forEach(function (item) {
2871
+ if (isObject(item)) {
2872
+ var newItem = _objectSpread2({}, item);
2873
+
2874
+ /** @type {string} */
2875
+ var id = newItem[keyField];
2876
+
2877
+ /** @type {string} */
2878
+ var pid = newItem[parentField];
2879
+ if (record[id]) {
2880
+ // @ts-ignore
2881
+ newItem[childrenField] = record[id];
2882
+ } else {
2883
+ // @ts-ignore
2884
+ newItem[childrenField] = record[id] = [];
2885
+ }
2886
+ if (pid) {
2887
+ if (!record[pid]) {
2888
+ record[pid] = [newItem];
2889
+ } else {
2890
+ record[pid].push(newItem);
2891
+ }
2892
+ } else {
2893
+ // @ts-ignore
2894
+ tree.push(newItem);
2895
+ }
2896
+ }
2897
+ });
2898
+ if (emptyChildrenValue !== 'array') {
2899
+ // @ts-ignore
2900
+ processEmptyChildren(tree, options);
2901
+ }
2902
+ return tree;
2903
+ }
2904
+
2905
+ /**
2906
+ * 树结构转列表数据
2907
+ *
2908
+ * @static
2909
+ * @alias module:Processor.treeToList
2910
+ * @since 4.14.0
2911
+ * @template {Record<string,any>} T
2912
+ * @template {keyof T} K
2913
+ * @template {Omit<T, K>} R
2914
+ * @param {T[]} tree 列表数据
2915
+ * @param {K} childrenField 子级字段名称
2916
+ * @returns {R[]} 列表数据
2917
+ * @example
2918
+ * const menus = [{ "id": "1", "name": "首页", "code": "trade", "pid": null }, { "id": "2", "name": "交易管理", "code": "trade", "pid": null, "children": [{ "id": "3", "name": "交易查询", "code": "trade-1", "pid": "2", "children": [{ "id": "4", "name": "交易查询-查询操作", "code": "trade-1-1", "pid": "3" }] }] }, { "id": "5", "name": "权限管理", "code": "authorization", "pid": null, "children": [{ "id": "6", "name": "角色管理", "code": "authorization-1", "pid": "5" }, { "id": "7", "name": "用户管理", "code": "authorization-2", "pid": "5" }] }];
2919
+ *
2920
+ * treeToList(menus, 'children'));
2921
+ * // [{"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"}]
2922
+ */
2923
+ function treeToList(tree, childrenField) {
2924
+ /** @type {R[]} */
2925
+ var list = [];
2926
+
2927
+ /**
2928
+ * 递归遍历
2929
+ * @param {T[]} arr 列表数据
2930
+ */
2931
+ function recusion(arr) {
2932
+ arr.forEach(function (item) {
2933
+ if (isObject(item)) {
2934
+ var newItem = _objectSpread2({}, item);
2935
+ // @ts-ignore
2936
+ list.push(newItem);
2937
+ if (newItem !== null && newItem !== void 0 && newItem[childrenField]) {
2938
+ if (Array.isArray(newItem[childrenField]) && newItem[childrenField].length > 0) {
2939
+ recusion(newItem[childrenField]);
2940
+ }
2941
+ delete newItem[childrenField];
2942
+ }
2943
+ } else {
2944
+ // @ts-ignore
2945
+ list.push(item);
2946
+ }
2947
+ });
2948
+ }
2949
+ recusion(tree);
2950
+ return list;
2951
+ }
2952
+
2953
+ /**
2954
+ * 查找树结构数据节点
2955
+ *
2956
+ * @static
2957
+ * @alias module:Other.findTreeNode
2958
+ * @since 4.14.0
2959
+ * @template {any} T
2960
+ * @template {(item: T) => boolean} F
2961
+ * @param {T[]} tree 树结构数据
2962
+ * @param {F} predicate 遍历每一项执行的函数,参数是当前遍历到的节点数据,如果返回 Truthy 将返回该节点
2963
+ * @param {string} [childrenField='children'] 子级字段名
2964
+ * @returns {T|undefined}
2965
+ * @example
2966
+ * const menus = [{ "id": "1", "name": "首页", "code": "trade", "pid": null }, { "id": "2", "name": "交易管理", "code": "trade", "pid": null, "children": [{ "id": "3", "name": "交易查询", "code": "trade-1", "pid": "2", "children": [{ "id": "4", "name": "交易查询-查询操作", "code": "trade-1-1", "pid": "3" }] }] }, { "id": "5", "name": "权限管理", "code": "authorization", "pid": null, "children": [{ "id": "6", "name": "角色管理", "code": "authorization-1", "pid": "5" }, { "id": "7", "name": "用户管理", "code": "authorization-2", "pid": "5" }] }];
2967
+ *
2968
+ * findTreeNode(menus, item=>item.id === '2');
2969
+ * // {"id":"2","name":"交易管理","code":"trade","pid":null,"children":[{"id":"3","name":"交易查询","code":"trade-1","pid":"2","children":[{"id":"4","name":"交易查询-查询操作","code":"trade-1-1","pid":"3"}]}]}
2970
+ *
2971
+ * findTreeNode(menus, item=>item.id === '7');
2972
+ * // {"id":"7","name":"用户管理","code":"authorization-2","pid":"5"}
2973
+ *
2974
+ * findTreeNode(menus, item=>item.id === 'not found');
2975
+ * // undefined
2976
+ */
2977
+ function findTreeNode(tree, predicate) {
2978
+ var childrenField = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children';
2979
+ var stack = [];
2980
+
2981
+ /** @type {T|undefined} */
2982
+ var node;
2983
+ var _iterator = _createForOfIteratorHelper(tree),
2984
+ _step;
2985
+ try {
2986
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2987
+ var item = _step.value;
2988
+ stack.push(item);
2989
+ while (stack.length) {
2990
+ /** @type {T} */
2991
+ // @ts-ignore
2992
+ var temp = stack.pop();
2993
+ if (predicate(temp)) {
2994
+ node = temp;
2995
+ break;
2996
+ }
2997
+
2998
+ /** @type {T[]} */
2999
+ // @ts-ignore
3000
+ var children = temp[childrenField] || [];
3001
+ stack.push.apply(stack, _toConsumableArray(children));
3002
+ }
3003
+ if (node) {
3004
+ break;
3005
+ }
3006
+ }
3007
+ } catch (err) {
3008
+ _iterator.e(err);
3009
+ } finally {
3010
+ _iterator.f();
3011
+ }
3012
+ return node;
3013
+ }
3014
+
3015
+ /**
3016
+ * 内部实现
3017
+ *
3018
+ * @private
3019
+ * @template {any} T
3020
+ * @template {(item: T) => boolean} F
3021
+ * @param {T[]} tree 树结构数据
3022
+ * @param {F} predicate 遍历每一项执行的函数,参数是当前遍历到的节点数据,如果返回 Truthy 将返回包含该节点的所有父级节点
3023
+ * @param {string} [childrenField='children'] 子级字段名
3024
+ * @param {T[]} [path=[]] 当前遍历路径
3025
+ * @returns {T[]}
3026
+ */
3027
+ function internalFindTreeSelect(tree, predicate) {
3028
+ var childrenField = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children';
3029
+ var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
3030
+ if (!tree) {
3031
+ return [];
3032
+ }
3033
+ var _iterator = _createForOfIteratorHelper(tree),
3034
+ _step;
3035
+ try {
3036
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
3037
+ var item = _step.value;
3038
+ path.push(item);
3039
+ if (predicate(item)) {
3040
+ return path;
3041
+ }
3042
+
3043
+ // @ts-ignore
3044
+ if (isObject(item) && Array.isArray(item[childrenField]) && item[childrenField].length > 0) {
3045
+ // @ts-ignore
3046
+ var findChildren = internalFindTreeSelect(item[childrenField], predicate, childrenField, path);
3047
+ if (findChildren.length > 0) {
3048
+ return findChildren;
3049
+ }
3050
+ }
3051
+ path.pop();
3052
+ }
3053
+ } catch (err) {
3054
+ _iterator.e(err);
3055
+ } finally {
3056
+ _iterator.f();
3057
+ }
3058
+ return [];
3059
+ }
3060
+
3061
+ /**
3062
+ * 查找包含当前节点的所有父级节点
3063
+ *
3064
+ * @static
3065
+ * @alias module:Other.findTreeSelect
3066
+ * @since 4.14.0
3067
+ * @template {any} T
3068
+ * @template {(item: T) => boolean} F
3069
+ * @param {T[]} tree 树结构数据
3070
+ * @param {F} predicate 遍历每一项执行的函数,参数是当前遍历到的节点数据,如果返回 Truthy 将返回包含该节点的所有父级节点
3071
+ * @param {string} [childrenField='children'] 子级字段名
3072
+ * @returns {T[]}
3073
+ * @example
3074
+ * const menus = [{ "id": "1", "name": "首页", "code": "trade", "pid": null }, { "id": "2", "name": "交易管理", "code": "trade", "pid": null, "children": [{ "id": "3", "name": "交易查询", "code": "trade-1", "pid": "2", "children": [{ "id": "4", "name": "交易查询-查询操作", "code": "trade-1-1", "pid": "3" }] }] }, { "id": "5", "name": "权限管理", "code": "authorization", "pid": null, "children": [{ "id": "6", "name": "角色管理", "code": "authorization-1", "pid": "5" }, { "id": "7", "name": "用户管理", "code": "authorization-2", "pid": "5" }] }];
3075
+ *
3076
+ * findTreeSelect(menus, item => item.id === '2');
3077
+ * // [{"id":"2","name":"交易管理","code":"trade","pid":null,"children":[{"id":"3","name":"交易查询","code":"trade-1","pid":"2","children":[{"id":"4","name":"交易查询-查询操作","code":"trade-1-1","pid":"3"}]}]}]
3078
+ *
3079
+ * findTreeSelect(menus, item => item.id === '7');
3080
+ * // [{"id":"5","name":"权限管理","code":"authorization","pid":null,"children":[{"id":"6","name":"角色管理","code":"authorization-1","pid":"5"},{"id":"7","name":"用户管理","code":"authorization-2","pid":"5"}]},{"id":"7","name":"用户管理","code":"authorization-2","pid":"5"}]
3081
+ *
3082
+ * findTreeSelect(menus, item => item.id === 'not found');
3083
+ * // []
3084
+ */
3085
+ function findTreeSelect(tree, predicate) {
3086
+ var childrenField = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children';
3087
+ return internalFindTreeSelect(tree, predicate, childrenField);
3088
+ }
3089
+
2667
3090
  /**
2668
3091
  * 精确乘法,支持多个数相乘,乘数默认为 1 。
2669
3092
  *
@@ -2679,29 +3102,25 @@
2679
3102
  * times(3, 0.6, 2, 10); // 36
2680
3103
  *
2681
3104
  */
2682
-
2683
3105
  function times() {
2684
3106
  for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) {
2685
3107
  nums[_key] = arguments[_key];
2686
3108
  }
2687
-
2688
3109
  var num1 = nums[0],
2689
- _nums$ = nums[1],
2690
- num2 = _nums$ === void 0 ? 1 : _nums$,
2691
- rest = nums.slice(2);
2692
-
3110
+ _nums$ = nums[1],
3111
+ num2 = _nums$ === void 0 ? 1 : _nums$,
3112
+ rest = nums.slice(2);
2693
3113
  if (rest.length > 0) {
2694
3114
  return times.apply(void 0, [times(num1, num2)].concat(_toConsumableArray(rest)));
2695
3115
  }
2696
-
2697
3116
  num1 = transformEffectiveNumber(num1);
2698
- num2 = transformEffectiveNumber(num2); // 兼容处理,如果参数包含无效数值时,返回 NaN
2699
- // @ts-ignore
3117
+ num2 = transformEffectiveNumber(num2);
2700
3118
 
3119
+ // 兼容处理,如果参数包含无效数值时,返回 NaN
3120
+ // @ts-ignore
2701
3121
  if (isNaN(num1) || isNaN(num2)) {
2702
3122
  return Number.NaN;
2703
3123
  }
2704
-
2705
3124
  var num1Changed = float2Fixed(num1);
2706
3125
  var num2Changed = float2Fixed(num2);
2707
3126
  var baseNum = digitLength(num1) + digitLength(num2);
@@ -2725,29 +3144,25 @@
2725
3144
  * plus(0.1, 0.2, 0.3, 0.4); // 1
2726
3145
  *
2727
3146
  */
2728
-
2729
3147
  function plus() {
2730
3148
  for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) {
2731
3149
  nums[_key] = arguments[_key];
2732
3150
  }
2733
-
2734
3151
  var num1 = nums[0],
2735
- _nums$ = nums[1],
2736
- num2 = _nums$ === void 0 ? 0 : _nums$,
2737
- rest = nums.slice(2);
2738
-
3152
+ _nums$ = nums[1],
3153
+ num2 = _nums$ === void 0 ? 0 : _nums$,
3154
+ rest = nums.slice(2);
2739
3155
  if (rest.length > 0) {
2740
3156
  return plus.apply(void 0, [plus(num1, num2)].concat(_toConsumableArray(rest)));
2741
3157
  }
2742
-
2743
3158
  num1 = transformEffectiveNumber(num1);
2744
- num2 = transformEffectiveNumber(num2); // 兼容处理,如果参数包含无效数值时,返回 NaN
2745
- // @ts-ignore
3159
+ num2 = transformEffectiveNumber(num2);
2746
3160
 
3161
+ // 兼容处理,如果参数包含无效数值时,返回 NaN
3162
+ // @ts-ignore
2747
3163
  if (isNaN(num1) || isNaN(num2)) {
2748
3164
  return Number.NaN;
2749
3165
  }
2750
-
2751
3166
  var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
2752
3167
  return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
2753
3168
  }
@@ -2767,29 +3182,25 @@
2767
3182
  * minus(1, 0.9, 0.02, 0.08); // 0
2768
3183
  *
2769
3184
  */
2770
-
2771
3185
  function minus() {
2772
3186
  for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) {
2773
3187
  nums[_key] = arguments[_key];
2774
3188
  }
2775
-
2776
3189
  var num1 = nums[0],
2777
- _nums$ = nums[1],
2778
- num2 = _nums$ === void 0 ? 0 : _nums$,
2779
- rest = nums.slice(2);
2780
-
3190
+ _nums$ = nums[1],
3191
+ num2 = _nums$ === void 0 ? 0 : _nums$,
3192
+ rest = nums.slice(2);
2781
3193
  if (rest.length > 0) {
2782
3194
  return minus.apply(void 0, [minus(num1, num2)].concat(_toConsumableArray(rest)));
2783
3195
  }
2784
-
2785
3196
  num1 = transformEffectiveNumber(num1);
2786
- num2 = transformEffectiveNumber(num2); // 兼容处理,如果参数包含无效数值时,返回 NaN
2787
- // @ts-ignore
3197
+ num2 = transformEffectiveNumber(num2);
2788
3198
 
3199
+ // 兼容处理,如果参数包含无效数值时,返回 NaN
3200
+ // @ts-ignore
2789
3201
  if (isNaN(num1) || isNaN(num2)) {
2790
3202
  return Number.NaN;
2791
3203
  }
2792
-
2793
3204
  var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
2794
3205
  return (times(num1, baseNum) - times(num2, baseNum)) / baseNum;
2795
3206
  }
@@ -2814,34 +3225,30 @@
2814
3225
  * divide('1.5 ', 0.5); // 3 Number('1.5 ') 转换为 1.5 ,1.5/0.5 = 3
2815
3226
  *
2816
3227
  */
2817
-
2818
3228
  function divide() {
2819
3229
  for (var _len = arguments.length, nums = new Array(_len), _key = 0; _key < _len; _key++) {
2820
3230
  nums[_key] = arguments[_key];
2821
3231
  }
2822
-
2823
3232
  var num1 = nums[0],
2824
- _nums$ = nums[1],
2825
- num2 = _nums$ === void 0 ? 1 : _nums$,
2826
- rest = nums.slice(2);
2827
-
3233
+ _nums$ = nums[1],
3234
+ num2 = _nums$ === void 0 ? 1 : _nums$,
3235
+ rest = nums.slice(2);
2828
3236
  if (rest.length > 0) {
2829
3237
  return divide.apply(void 0, [divide(num1, num2)].concat(_toConsumableArray(rest)));
2830
3238
  }
2831
-
2832
3239
  num1 = transformEffectiveNumber(num1);
2833
- num2 = transformEffectiveNumber(num2); // 兼容处理,如果参数包含无效数值时,返回 NaN
2834
- // @ts-ignore
3240
+ num2 = transformEffectiveNumber(num2);
2835
3241
 
3242
+ // 兼容处理,如果参数包含无效数值时,返回 NaN
3243
+ // @ts-ignore
2836
3244
  if (isNaN(num1) || isNaN(num2)) {
2837
3245
  return Number.NaN;
2838
3246
  }
2839
-
2840
3247
  var num1Changed = float2Fixed(num1);
2841
3248
  var num2Changed = float2Fixed(num2);
2842
3249
  checkBoundary(num1Changed);
2843
- checkBoundary(num2Changed); // fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
2844
-
3250
+ checkBoundary(num2Changed);
3251
+ // fix: 类似 10 ** -4 为 0.00009999999999999999,strip 修正
2845
3252
  return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1))));
2846
3253
  }
2847
3254
 
@@ -2861,16 +3268,15 @@
2861
3268
  * round(4060, -2); // 4100
2862
3269
  *
2863
3270
  */
2864
-
2865
3271
  function round(num) {
2866
3272
  var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2867
- num = transformEffectiveNumber(num); // 兼容处理,如果参数包含无效数值时,返回 NaN
2868
- // @ts-ignore
3273
+ num = transformEffectiveNumber(num);
2869
3274
 
3275
+ // 兼容处理,如果参数包含无效数值时,返回 NaN
3276
+ // @ts-ignore
2870
3277
  if (isNaN(num)) {
2871
3278
  return Number.NaN;
2872
3279
  }
2873
-
2874
3280
  var base = Math.pow(10, precision);
2875
3281
  return divide(Math.round(times(num, base)), base);
2876
3282
  }
@@ -2902,6 +3308,8 @@
2902
3308
  });
2903
3309
  }
2904
3310
 
3311
+ // 参考了: https://github.com/ant-design/ant-design-mobile/blob/v2/components/input-item/index.tsx#L240
3312
+
2905
3313
  /**
2906
3314
  * 计算输入框的值格式化后光标位置
2907
3315
  *
@@ -2922,27 +3330,24 @@
2922
3330
  * @param {'mobile'|'bankCard'} [options.type] 格式化类型,内置手机号码和银行卡号特殊处理
2923
3331
  * @returns {number} 格式化后的光标位置
2924
3332
  */
2925
-
2926
3333
  function calculateCursorPosition(prevPos, prevCtrlValue, rawValue, ctrlValue) {
2927
3334
  var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
2928
3335
  var _options$placeholderC = options.placeholderChar,
2929
- placeholderChar = _options$placeholderC === void 0 ? ' ' : _options$placeholderC,
2930
- _options$maskReg = options.maskReg,
2931
- maskReg = _options$maskReg === void 0 ? /\D/g : _options$maskReg,
2932
- type = options.type;
3336
+ placeholderChar = _options$placeholderC === void 0 ? ' ' : _options$placeholderC,
3337
+ _options$maskReg = options.maskReg,
3338
+ maskReg = _options$maskReg === void 0 ? /\D/g : _options$maskReg,
3339
+ type = options.type;
2933
3340
  var realCtrlValue = normalizeString(prevCtrlValue);
2934
3341
  var realRawValue = normalizeString(rawValue);
2935
3342
  var placeholderChars = Array.isArray(placeholderChar) ? placeholderChar : [placeholderChar];
2936
3343
  var editLength = realRawValue.length - realCtrlValue.length;
2937
3344
  var isAddition = editLength > 0;
2938
3345
  var pos = prevPos;
2939
-
2940
3346
  if (isAddition) {
2941
3347
  var additionStr = realRawValue.substring(pos - editLength, pos);
2942
3348
  var ctrlCharCount = additionStr.replace(maskReg, '').length;
2943
3349
  pos -= editLength - ctrlCharCount;
2944
3350
  var placeholderCharCount = 0;
2945
-
2946
3351
  while (ctrlCharCount > 0) {
2947
3352
  if (placeholderChars.indexOf(ctrlValue.charAt(pos - ctrlCharCount + placeholderCharCount)) !== -1) {
2948
3353
  placeholderCharCount++;
@@ -2950,20 +3355,18 @@
2950
3355
  ctrlCharCount--;
2951
3356
  }
2952
3357
  }
2953
-
2954
3358
  pos += placeholderCharCount;
2955
3359
  }
2956
-
2957
3360
  if (type === 'mobile' && (pos === 4 || pos === 9) || type === 'bankCard' && pos > 0 && pos % 5 === 0) {
2958
3361
  pos -= 1;
2959
3362
  }
2960
-
2961
3363
  return pos;
2962
3364
  }
2963
3365
 
2964
3366
  var numberChars = '0123456789';
2965
3367
  var letterChars = 'abcdefghijklmnopqrstuvwxyz';
2966
3368
  var defaultChars = numberChars + letterChars + letterChars.toUpperCase();
3369
+
2967
3370
  /**
2968
3371
  * @private
2969
3372
  * @param {number} [len=0] 长度
@@ -2971,19 +3374,17 @@
2971
3374
  * @param {string} [prefix=''] 前缀部分,不计入长度
2972
3375
  * @returns {string}
2973
3376
  */
2974
-
2975
3377
  function internalRandomString() {
2976
3378
  var len = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2977
3379
  var optionalChars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultChars;
2978
3380
  var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
2979
-
2980
3381
  while (len-- > 0) {
2981
3382
  var r = optionalChars[Math.floor(Math.random() * optionalChars.length)];
2982
3383
  return internalRandomString(len, optionalChars, prefix + r);
2983
3384
  }
2984
-
2985
3385
  return prefix;
2986
3386
  }
3387
+
2987
3388
  /**
2988
3389
  * 生成随机字符串
2989
3390
  *
@@ -3003,12 +3404,9 @@
3003
3404
  * randomString(8, 'abcefg'); // bcgcfabg
3004
3405
  *
3005
3406
  */
3006
-
3007
-
3008
3407
  function randomString() {
3009
3408
  var len = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
3010
3409
  var optionalChars = arguments.length > 1 ? arguments[1] : undefined;
3011
-
3012
3410
  var realChars = typeof optionalChars === 'string' && optionalChars ? optionalChars : defaultChars;
3013
3411
  return internalRandomString(len, realChars);
3014
3412
  }
@@ -3031,21 +3429,17 @@
3031
3429
  * strlen('🍎'); // 4
3032
3430
  *
3033
3431
  */
3034
-
3035
3432
  function strlen(str) {
3036
3433
  var realStr = normalizeString(str);
3037
3434
  var len = 0;
3038
-
3039
3435
  for (var i = 0; i < realStr.length; i++) {
3040
3436
  var c = realStr.charCodeAt(i);
3041
-
3042
3437
  if (c >= 0x0001 && c <= 0x007e || 0xff60 <= c && c <= 0xff9f) {
3043
3438
  len++;
3044
3439
  } else {
3045
3440
  len += 2;
3046
3441
  }
3047
3442
  }
3048
-
3049
3443
  return len;
3050
3444
  }
3051
3445
 
@@ -3054,9 +3448,11 @@
3054
3448
  exports.calculateCursorPosition = calculateCursorPosition;
3055
3449
  exports.dataURLToBlob = dataURLToBlob;
3056
3450
  exports.divide = divide;
3451
+ exports.findTreeNode = findTreeNode;
3452
+ exports.findTreeSelect = findTreeSelect;
3057
3453
  exports.formatBankCard = formatBankCard;
3058
3454
  exports.formatMobile = formatMobile;
3059
- exports.formatMoney = formatMoney;
3455
+ exports.formatMoney = formatMoney$1;
3060
3456
  exports.isBankCard = isBankCard;
3061
3457
  exports.isBusinessLicense = isBusinessLicense;
3062
3458
  exports.isChinese = isChinese;
@@ -3078,6 +3474,7 @@
3078
3474
  exports.isUrl = isUrl;
3079
3475
  exports.isVehicle = isVehicle;
3080
3476
  exports.isWX = isWX;
3477
+ exports.listToTree = listToTree;
3081
3478
  exports.minus = minus;
3082
3479
  exports.normalizeString = normalizeString;
3083
3480
  exports.numberToChinese = numberToChinese;
@@ -3092,11 +3489,13 @@
3092
3489
  exports.setDisableWarning = setDisableWarning;
3093
3490
  exports.strlen = strlen;
3094
3491
  exports.times = times;
3492
+ exports.transformFieldNames = transformFieldNames;
3493
+ exports.treeToList = treeToList;
3095
3494
  exports.validatePassword = validatePassword;
3096
3495
  exports.version = version;
3097
3496
  exports.waitTime = waitTime;
3098
3497
 
3099
3498
  Object.defineProperty(exports, '__esModule', { value: true });
3100
3499
 
3101
- })));
3500
+ }));
3102
3501
  //# sourceMappingURL=util-helpers.js.map