util-helpers 4.17.1 → 4.17.2

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
@@ -92,6 +92,7 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
92
92
  - [isIPv4](https://doly-dev.github.io/util-helpers/module-Validator.html#.isIPv4) - IPv4
93
93
  - [isIPv6](https://doly-dev.github.io/util-helpers/module-Validator.html#.isIPv6) - IPv6
94
94
  - [isUrl](https://doly-dev.github.io/util-helpers/module-Validator.html#.isUrl) - URL
95
+ - [isValidNumber](https://doly-dev.github.io/util-helpers/module-Validator.html#.isValidNumber) - 有效数字
95
96
  - [isBusinessLicense](https://doly-dev.github.io/util-helpers/module-Validator.html#.isBusinessLicense) - 营业执照,也叫工商注册号
96
97
  - [validatePassword](https://doly-dev.github.io/util-helpers/module-Validator.html#.validatePassword) - 验证密码
97
98
  - 其他
@@ -273,7 +273,7 @@
273
273
  function setDisableWarning(bool) {
274
274
  config.disableWarning = !!bool;
275
275
  }
276
- var version = "4.17.1";
276
+ var version = "4.17.2";
277
277
 
278
278
  function devWarn() {
279
279
  var args = [];
@@ -522,9 +522,6 @@
522
522
  return reg$1.test(valueStr);
523
523
  }
524
524
 
525
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
526
- var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
527
-
528
525
  function isBlob(value) {
529
526
  return isType(value, 'Blob');
530
527
  }
@@ -546,6 +543,29 @@
546
543
  return isType(value, 'Symbol');
547
544
  }
548
545
 
546
+ function isValidNumber(value, strict) {
547
+ if (strict === void 0) { strict = false; }
548
+ var ret;
549
+ if (strict) {
550
+ ret = typeof value === 'string' && value !== '' ? Number(value) : value;
551
+ }
552
+ else {
553
+ if (typeof value === 'number') {
554
+ ret = value;
555
+ }
556
+ else if (isSymbol(value)) {
557
+ ret = Number.NaN;
558
+ }
559
+ else {
560
+ ret = Number(value);
561
+ }
562
+ }
563
+ return typeof ret === 'number' && !Number.isNaN(ret);
564
+ }
565
+
566
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
567
+ var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
568
+
549
569
  function transformEffectiveNumber(value) {
550
570
  var ret;
551
571
  if (isString(value)) {
@@ -1598,6 +1618,7 @@
1598
1618
  exports.isTWCard = isTWCard;
1599
1619
  exports.isTelephone = isTelephone;
1600
1620
  exports.isUrl = isUrl;
1621
+ exports.isValidNumber = isValidNumber;
1601
1622
  exports.isVehicle = isVehicle;
1602
1623
  exports.isWX = isWX;
1603
1624
  exports.listToTree = listToTree;