util-helpers 4.17.1 → 4.17.3

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
  - 其他
@@ -178,6 +178,8 @@
178
178
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
179
179
  PERFORMANCE OF THIS SOFTWARE.
180
180
  ***************************************************************************** */
181
+ /* global Reflect, Promise */
182
+
181
183
 
182
184
  var __assign = function() {
183
185
  __assign = Object.assign || function __assign(t) {
@@ -273,7 +275,7 @@
273
275
  function setDisableWarning(bool) {
274
276
  config.disableWarning = !!bool;
275
277
  }
276
- var version = "4.17.1";
278
+ var version = "4.17.3";
277
279
 
278
280
  function devWarn() {
279
281
  var args = [];
@@ -522,9 +524,6 @@
522
524
  return reg$1.test(valueStr);
523
525
  }
524
526
 
525
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
526
- var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
527
-
528
527
  function isBlob(value) {
529
528
  return isType(value, 'Blob');
530
529
  }
@@ -546,6 +545,29 @@
546
545
  return isType(value, 'Symbol');
547
546
  }
548
547
 
548
+ function isValidNumber(value, strict) {
549
+ if (strict === void 0) { strict = false; }
550
+ var ret;
551
+ if (strict) {
552
+ ret = typeof value === 'string' && value !== '' ? Number(value) : value;
553
+ }
554
+ else {
555
+ if (typeof value === 'number') {
556
+ ret = value;
557
+ }
558
+ else if (isSymbol(value)) {
559
+ ret = Number.NaN;
560
+ }
561
+ else {
562
+ ret = Number(value);
563
+ }
564
+ }
565
+ return typeof ret === 'number' && !Number.isNaN(ret);
566
+ }
567
+
568
+ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
569
+ var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
570
+
549
571
  function transformEffectiveNumber(value) {
550
572
  var ret;
551
573
  if (isString(value)) {
@@ -1598,6 +1620,7 @@
1598
1620
  exports.isTWCard = isTWCard;
1599
1621
  exports.isTelephone = isTelephone;
1600
1622
  exports.isUrl = isUrl;
1623
+ exports.isValidNumber = isValidNumber;
1601
1624
  exports.isVehicle = isVehicle;
1602
1625
  exports.isWX = isWX;
1603
1626
  exports.listToTree = listToTree;