util-helpers 5.5.1 → 5.7.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.
package/README.md CHANGED
@@ -88,7 +88,6 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
88
88
  - [treeToList](https://doly-dev.github.io/util-helpers/module-Processor.html#.treeToList) - 树结构转列表数据
89
89
  - 数据验证
90
90
  - [isBankCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBankCard) - 银行卡
91
- - [isBusinessLicense](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBusinessLicense) - 营业执照,也叫工商注册号
92
91
  - [isChinese](https://doly-dev.github.io/util-helpers/module-Validator.html#.isChinese) - 中文
93
92
  - [isEmail](https://doly-dev.github.io/util-helpers/module-Validator.html#.isEmail) - 邮箱
94
93
  - [isHMCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isHMCard) - 港澳居民来往内地通行证,俗称回乡证或回乡卡
@@ -100,10 +99,10 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
100
99
  - [isPassword](https://doly-dev.github.io/util-helpers/module-Validator.html#.isPassword) 密码强度
101
100
  - [isPostcode](https://doly-dev.github.io/util-helpers/module-Validator.html#.isPostcode) - 邮政编码
102
101
  - [isQQ](https://doly-dev.github.io/util-helpers/module-Validator.html#.isQQ) - QQ 号
103
- - [isSocialCreditCode](https://doly-dev.github.io/util-helpers/module-Validator.html#.isSocialCreditCode) - 统一社会信用代码,也叫三证合一组织代码
104
102
  - [isSwiftCode](https://doly-dev.github.io/util-helpers/module-Validator.html#.isSwiftCode) - Swift Code
105
103
  - [isTWCard](https://doly-dev.github.io/util-helpers/module-Validator.html#.isTWCard) - 台湾居民来往大陆通行证,俗称台胞证
106
104
  - [isTelephone](https://doly-dev.github.io/util-helpers/module-Validator.html#.isTelephone) - 固定电话
105
+ - [isUnifiedIdentifier](https://doly-dev.github.io/util-helpers/module-Validator.html#.isUnifiedIdentifier) - 统一社会信用代码,也叫三证合一组织代码
107
106
  - [isUrl](https://doly-dev.github.io/util-helpers/module-Validator.html#.isUrl) - URL
108
107
  - [isValidNumber](https://doly-dev.github.io/util-helpers/module-Validator.html#.isValidNumber) - 有效数字
109
108
  - [isVehicle](https://doly-dev.github.io/util-helpers/module-Validator.html#.isVehicle) - 车牌号
@@ -29,13 +29,14 @@
29
29
  var selfExisted = typeof self === stringObject && self;
30
30
  var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
31
31
  var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
32
- var numberTag = '[object Number]';
33
- var stringTag = '[object String]';
34
- var symbolTag = '[object Symbol]';
35
- var functionTags = ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy'].map(function (item) { return '[object ' + item + ']'; });
36
- var blobTag = '[object Blob]';
37
- var fileTag = '[object File]';
38
- var objectTag = '[object Object]';
32
+ var tagPrefix = '[object ';
33
+ var numberTag = tagPrefix + 'Number]';
34
+ var stringTag = tagPrefix + 'String]';
35
+ var symbolTag = tagPrefix + 'Symbol]';
36
+ var functionTags = ['Function', 'AsyncFunction', 'GeneratorFunction', 'Proxy'].map(function (item) { return tagPrefix + item + ']'; });
37
+ var blobTag = tagPrefix + 'Blob]';
38
+ var fileTag = tagPrefix + 'File]';
39
+ var objectTag = tagPrefix + 'Object]';
39
40
 
40
41
  function isArray(value) {
41
42
  return Array.isArray(value);
@@ -429,12 +430,6 @@
429
430
  };
430
431
  };
431
432
 
432
- var idCounter = 0;
433
- '_' + mathRandom().toString(36).substring(2, 4);
434
- function uniqueId(prefix) {
435
- return '' + prefix + ++idCounter;
436
- }
437
-
438
433
  var reg$b = /^1[3456789]\d{9}$/;
439
434
  function isMobile(value) {
440
435
  var valueStr = toString(value);
@@ -549,7 +544,7 @@
549
544
  var checkCodeIndex = remainder !== 0 ? 31 - remainder : 0;
550
545
  return baseCodeArr[checkCodeIndex];
551
546
  }
552
- function isSocialCreditCode(value, options) {
547
+ function isUnifiedIdentifier(value, options) {
553
548
  var valueStr = toString(value);
554
549
  var _a = (options || {}).checkCode, needCheckCode = _a === void 0 ? true : _a;
555
550
  var passBaseRule = baseReg$1.test(valueStr);
@@ -561,7 +556,9 @@
561
556
  var checkCode = sumCheckCode$1(preCode);
562
557
  return lastCode === checkCode;
563
558
  }
564
- isSocialCreditCode.sumCheckCode = sumCheckCode$1;
559
+ isUnifiedIdentifier.sumCheckCode = sumCheckCode$1;
560
+
561
+ var isSocialCreditCode = isUnifiedIdentifier;
565
562
 
566
563
  var config$1 = {
567
564
  disableWarning: true
@@ -836,29 +833,6 @@
836
833
  return typeof ret === 'number' && !isNaN(ret);
837
834
  }
838
835
 
839
- var checkResult = function () {
840
- var args_1 = [];
841
- for (var _i = 0; _i < arguments.length; _i++) {
842
- args_1[_i] = arguments[_i];
843
- }
844
- return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (fn) {
845
- var _a, _b, err, ret;
846
- if (fn === void 0) { fn = function () { return true; }; }
847
- var args = [];
848
- for (_a = 1; _a < arguments.length; _a++) {
849
- args[_a - 1] = arguments[_a];
850
- }
851
- return __generator(this, function (_c) {
852
- switch (_c.label) {
853
- case 0: return [4, tryit(fn).apply(void 0, __spreadArray([], __read(args), false))];
854
- case 1:
855
- _b = __read.apply(void 0, [_c.sent(), 2]), err = _b[0], ret = _b[1];
856
- return [2, !err && ret !== false];
857
- }
858
- });
859
- });
860
- };
861
-
862
836
  var radixReg = /^[-+]?0[b|o|x]\d+/i;
863
837
  var dotNumberStringReg = /^\.\d+/;
864
838
  function transformEffectiveNumber(value) {
@@ -1462,7 +1436,7 @@
1462
1436
  loadend: onLoadEnd
1463
1437
  };
1464
1438
  var eventKeys = objectKeys(events);
1465
- eventKeys.map(function (item) {
1439
+ eventKeys.forEach(function (item) {
1466
1440
  var func = events[item];
1467
1441
  if (func) {
1468
1442
  xhr.addEventListener(item, func);
@@ -1973,6 +1947,29 @@
1973
1947
  return len;
1974
1948
  }
1975
1949
 
1950
+ var checkResult = function () {
1951
+ var args_1 = [];
1952
+ for (var _i = 0; _i < arguments.length; _i++) {
1953
+ args_1[_i] = arguments[_i];
1954
+ }
1955
+ return __awaiter(void 0, __spreadArray([], __read(args_1), false), void 0, function (fn) {
1956
+ var _a, _b, err, ret;
1957
+ if (fn === void 0) { fn = function () { return true; }; }
1958
+ var args = [];
1959
+ for (_a = 1; _a < arguments.length; _a++) {
1960
+ args[_a - 1] = arguments[_a];
1961
+ }
1962
+ return __generator(this, function (_c) {
1963
+ switch (_c.label) {
1964
+ case 0: return [4, tryit(fn).apply(void 0, __spreadArray([], __read(args), false))];
1965
+ case 1:
1966
+ _b = __read.apply(void 0, [_c.sent(), 2]), err = _b[0], ret = _b[1];
1967
+ return [2, !err && ret !== false];
1968
+ }
1969
+ });
1970
+ });
1971
+ };
1972
+
1976
1973
  function transformFieldNames(data, fieldNames, childrenField, nodeAssign) {
1977
1974
  if (nodeAssign === void 0) { nodeAssign = 'spread'; }
1978
1975
  if (!isArray(data)) {
@@ -2203,7 +2200,7 @@
2203
2200
  return internalFindTreeSelect(tree, predicate, childrenField);
2204
2201
  }
2205
2202
 
2206
- var VERSION = "5.5.1";
2203
+ var VERSION = "5.7.0";
2207
2204
 
2208
2205
  /**
2209
2206
  * 事件触发器,支持浏览器端和 node 端。
@@ -3193,9 +3190,10 @@
3193
3190
  }(EmitterPro));
3194
3191
 
3195
3192
  var AsyncMemo = (function () {
3196
- function AsyncMemo(options) {
3193
+ function AsyncMemo(options, ns) {
3194
+ if (ns === void 0) { ns = 'uh_async_memo'; }
3197
3195
  this.promiseCache = {};
3198
- this.cache = new Cache(uniqueId('uh_async_memo'), options);
3196
+ this.cache = new Cache(ns, options);
3199
3197
  }
3200
3198
  AsyncMemo.prototype.run = function (asyncFn, key, options) {
3201
3199
  var _this = this;
@@ -3269,6 +3267,7 @@
3269
3267
  exports.isSwiftCode = isSwiftCode;
3270
3268
  exports.isTWCard = isTWCard;
3271
3269
  exports.isTelephone = isTelephone;
3270
+ exports.isUnifiedIdentifier = isUnifiedIdentifier;
3272
3271
  exports.isUrl = isUrl;
3273
3272
  exports.isValidNumber = isValidNumber;
3274
3273
  exports.isVehicle = isVehicle;