util-helpers 5.7.6 → 5.7.8

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') {
@@ -764,7 +764,7 @@
764
764
  }
765
765
  isBusinessLicense.sumCheckCode = sumCheckCode;
766
766
 
767
- var regHMCard = /^[hm]{1}([0-9]{10}|[0-9]{8})$/i;
767
+ var regHMCard = /^[hm]{1}[0-9]{8}$/i;
768
768
  function isHMCard(value) {
769
769
  var valueStr = toString(value);
770
770
  return regHMCard.test(valueStr);
@@ -1813,16 +1813,19 @@
1813
1813
 
1814
1814
  var loadScript = function (_src, options) {
1815
1815
  var finalOptions;
1816
- if (typeof _src === 'object') {
1816
+ if (isObject(_src)) {
1817
1817
  finalOptions = _src;
1818
1818
  }
1819
1819
  else if (typeof _src === 'string') {
1820
1820
  finalOptions = __assign({ src: _src }, options);
1821
1821
  }
1822
+ else {
1823
+ finalOptions = options || {};
1824
+ }
1822
1825
  return new Promise(function (resolve, reject) {
1823
1826
  var container = document.head || document.getElementsByTagName('head')[0] || document.body;
1824
1827
  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"]);
1828
+ 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
1829
  var props = __assign({ async: true, type: 'text/javascript' }, restOptions);
1827
1830
  for (var key in props) {
1828
1831
  script[key] = props[key];
@@ -2199,7 +2202,7 @@
2199
2202
  return internalFindTreeSelect(tree, predicate, childrenField);
2200
2203
  }
2201
2204
 
2202
- var VERSION = "5.7.6";
2205
+ var VERSION = "5.7.8";
2203
2206
 
2204
2207
  /**
2205
2208
  * 事件触发器,支持浏览器端和 node 端。
@@ -2576,8 +2579,9 @@
2576
2579
  storage.removeItem(key);
2577
2580
  }
2578
2581
  return isSupport;
2582
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2579
2583
  }
2580
- catch (e) {
2584
+ catch (err) {
2581
2585
  console.error("[cache2] ".concat(storage, " is not supported. The default memory cache will be used."));
2582
2586
  return false;
2583
2587
  }
@@ -2585,8 +2589,9 @@
2585
2589
  function parse(value, reviver) {
2586
2590
  try {
2587
2591
  return JSON.parse(value, reviver);
2592
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2588
2593
  }
2589
- catch (e) {
2594
+ catch (err) {
2590
2595
  return value;
2591
2596
  }
2592
2597
  }