util-helpers 5.7.6 → 5.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,10 @@ pnpm add util-helpers
26
26
 
27
27
  如果你的项目使用的是原生方式开发,可以在浏览器中使用 `script` 标签直接引入文件,并使用全局变量 `utilHelpers` 。
28
28
 
29
- `npm` 包的 [util-helpers/dist](https://www.npmjs.com/package/util-helpers?activeTab=code) 目录下提供了 `UMD` 包 `util-helpers.js` 以及 `util-helpers.min.js`。你也可以通过 [UNPKG](https://unpkg.com/browse/util-helpers/dist/) 下载到本地进行使用。或者直接使用 [UNPKG 线上版本](https://unpkg.com/util-helpers/dist/util-helpers.min.js)<sup> _注意版本_ </sup>。
29
+ `npm` 包的 [util-helpers/dist](https://www.npmjs.com/package/util-helpers?activeTab=code) 目录下提供了 `UMD` 包 `util-helpers.js` 以及 `util-helpers.min.js`。你也可以直接使用`cdn`:
30
+
31
+ - jsdelivr: <https://cdn.jsdelivr.net/npm/util-helpers@5>
32
+ - unpkg: <https://unpkg.com/util-helpers@5>
30
33
 
31
34
  ## 示例
32
35
 
@@ -38,8 +38,8 @@
38
38
  var fileTag = tagPrefix + 'File]';
39
39
  var objectTag = tagPrefix + 'Object]';
40
40
 
41
- function isArray(value) {
42
- return Array.isArray(value);
41
+ function isNil(value) {
42
+ return value == null;
43
43
  }
44
44
 
45
45
  function isObjectLike(value) {
@@ -88,6 +88,10 @@
88
88
  return remainder ? result - remainder : result;
89
89
  }
90
90
 
91
+ function isArray(value) {
92
+ return Array.isArray(value);
93
+ }
94
+
91
95
  function identity(value) {
92
96
  return value;
93
97
  }
@@ -183,10 +187,6 @@
183
187
  return typeof value === 'number' || getTag(value) === numberTag;
184
188
  }
185
189
 
186
- function isNil(value) {
187
- return value == null;
188
- }
189
-
190
190
  var symbolToString = symbolProto ? symbolProto.toString : nativeUndefined$1;
191
191
  function baseToString(value) {
192
192
  if (typeof value === 'string') {
@@ -423,7 +423,7 @@
423
423
  return reg$9.test(valueStr);
424
424
  }
425
425
 
426
- 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;
426
+ 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;
427
427
  function check(id) {
428
428
  var index, sum;
429
429
  for (sum = index = 0; index < 17; index++) {
@@ -439,16 +439,10 @@
439
439
  }
440
440
  function isIdCard(value, options) {
441
441
  if (options === void 0) { options = {}; }
442
- var _a = options.loose, loose = _a === void 0 ? false : _a, _b = options.checkCode, checkCode = _b === void 0 ? true : _b;
442
+ var _a = options.checkCode, checkCode = _a === void 0 ? true : _a;
443
443
  var valueStr = toString(value);
444
- if (valueStr.length === 15 && loose) {
445
- return regIdCard$1.test(valueStr);
446
- }
447
444
  if (valueStr.length === 18 && regIdCard$1.test(valueStr)) {
448
- if (checkCode) {
449
- return check(valueStr);
450
- }
451
- return true;
445
+ return checkCode ? check(valueStr) : true;
452
446
  }
453
447
  return false;
454
448
  }
@@ -764,7 +758,7 @@
764
758
  }
765
759
  isBusinessLicense.sumCheckCode = sumCheckCode;
766
760
 
767
- var regHMCard = /^[hm]{1}([0-9]{10}|[0-9]{8})$/i;
761
+ var regHMCard = /^[hm]{1}[0-9]{8}$/i;
768
762
  function isHMCard(value) {
769
763
  var valueStr = toString(value);
770
764
  return regHMCard.test(valueStr);
@@ -1813,16 +1807,19 @@
1813
1807
 
1814
1808
  var loadScript = function (_src, options) {
1815
1809
  var finalOptions;
1816
- if (typeof _src === 'object') {
1810
+ if (isObject(_src)) {
1817
1811
  finalOptions = _src;
1818
1812
  }
1819
1813
  else if (typeof _src === 'string') {
1820
1814
  finalOptions = __assign({ src: _src }, options);
1821
1815
  }
1816
+ else {
1817
+ finalOptions = options || {};
1818
+ }
1822
1819
  return new Promise(function (resolve, reject) {
1823
1820
  var container = document.head || document.getElementsByTagName('head')[0] || document.body;
1824
1821
  var script = document.createElement('script');
1825
- var _a = finalOptions || {}, src = _a.src, attrs = _a.attrs, _b = _a.destroyOnError, destroyOnError = _b === void 0 ? true : _b, onload = _a.onload, onerror = _a.onerror, restOptions = __rest(_a, ["src", "attrs", "destroyOnError", "onload", "onerror"]);
1822
+ var src = finalOptions.src, attrs = finalOptions.attrs, _a = finalOptions.destroyOnError, destroyOnError = _a === void 0 ? true : _a, onload = finalOptions.onload, onerror = finalOptions.onerror, restOptions = __rest(finalOptions, ["src", "attrs", "destroyOnError", "onload", "onerror"]);
1826
1823
  var props = __assign({ async: true, type: 'text/javascript' }, restOptions);
1827
1824
  for (var key in props) {
1828
1825
  script[key] = props[key];
@@ -2199,7 +2196,7 @@
2199
2196
  return internalFindTreeSelect(tree, predicate, childrenField);
2200
2197
  }
2201
2198
 
2202
- var VERSION = "5.7.6";
2199
+ var VERSION = "5.7.7";
2203
2200
 
2204
2201
  /**
2205
2202
  * 事件触发器,支持浏览器端和 node 端。
@@ -2576,8 +2573,9 @@
2576
2573
  storage.removeItem(key);
2577
2574
  }
2578
2575
  return isSupport;
2576
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2579
2577
  }
2580
- catch (e) {
2578
+ catch (err) {
2581
2579
  console.error("[cache2] ".concat(storage, " is not supported. The default memory cache will be used."));
2582
2580
  return false;
2583
2581
  }
@@ -2585,8 +2583,9 @@
2585
2583
  function parse(value, reviver) {
2586
2584
  try {
2587
2585
  return JSON.parse(value, reviver);
2586
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2588
2587
  }
2589
- catch (e) {
2588
+ catch (err) {
2590
2589
  return value;
2591
2590
  }
2592
2591
  }