util-helpers 4.20.4 → 4.20.6

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/esm/VERSION.js CHANGED
@@ -1,4 +1,4 @@
1
- var VERSION = "4.20.4";
1
+ var VERSION = "4.20.6";
2
2
  var VERSION$1 = VERSION;
3
3
 
4
4
  export { VERSION$1 as default };
@@ -1,3 +1,5 @@
1
+ import { isNaN } from 'ut2';
2
+
1
3
  function bytesToSize(bytes, options) {
2
4
  if (options === void 0) { options = {}; }
3
5
  var _a = options.spaceMark, spaceMark = _a === void 0 ? ' ' : _a, _b = options.precision, precision = _b === void 0 ? 2 : _b;
package/esm/index.js CHANGED
@@ -63,6 +63,6 @@ export { default as findTreeSelect } from './findTreeSelect.js';
63
63
  export { setDisableWarning } from './utils/config.js';
64
64
  export { default as VERSION } from './VERSION.js';
65
65
 
66
- var version = "4.20.4";
66
+ var version = "4.20.6";
67
67
 
68
68
  export { version };
@@ -1,4 +1,4 @@
1
- import { isSymbol } from 'ut2';
1
+ import { isSymbol, isNaN } from 'ut2';
2
2
 
3
3
  function isValidNumber(value, strict) {
4
4
  if (strict === void 0) { strict = false; }
@@ -17,7 +17,7 @@ function isValidNumber(value, strict) {
17
17
  ret = Number(value);
18
18
  }
19
19
  }
20
- return typeof ret === 'number' && !Number.isNaN(ret);
20
+ return typeof ret === 'number' && !isNaN(ret);
21
21
  }
22
22
 
23
23
  export { isValidNumber as default };
@@ -1,3 +1,4 @@
1
+ import { isNaN } from 'ut2';
1
2
  import { checkBoundary } from './utils/math.util.js';
2
3
  import devWarn from './utils/devWarn.js';
3
4
 
@@ -1,3 +1,5 @@
1
+ import { toNumber } from 'ut2';
2
+
1
3
  var numberChars = '0123456789';
2
4
  var letterChars = 'abcdefghijklmnopqrstuvwxyz';
3
5
  var defaultChars = numberChars + letterChars + letterChars.toUpperCase();
@@ -12,7 +14,7 @@ function internalRandomString(len, optionalChars, prefix) {
12
14
  function randomString(len, optionalChars) {
13
15
  if (len === void 0) { len = 0; }
14
16
  var realChars = typeof optionalChars === 'string' && optionalChars ? optionalChars : defaultChars;
15
- return internalRandomString(len, realChars);
17
+ return internalRandomString(toNumber(len), realChars);
16
18
  }
17
19
 
18
20
  export { randomString as default };
@@ -1,4 +1,4 @@
1
- import { isString, isSymbol, isNumber, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from 'ut2';
1
+ import { isString, isNaN, isSymbol, isNumber, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from 'ut2';
2
2
  import devWarn from './devWarn.js';
3
3
 
4
4
  function transformEffectiveNumber(value) {
@@ -8,7 +8,7 @@ function transformEffectiveNumber(value) {
8
8
  if (ret === '') {
9
9
  ret = Number(ret);
10
10
  }
11
- else if (Number.isNaN(Number(ret))) {
11
+ else if (isNaN(Number(ret))) {
12
12
  ret = Number.NaN;
13
13
  }
14
14
  }
@@ -21,7 +21,7 @@ function transformEffectiveNumber(value) {
21
21
  else {
22
22
  ret = value;
23
23
  }
24
- if (Number.isNaN(ret)) {
24
+ if (isNaN(ret)) {
25
25
  return Number.NaN;
26
26
  }
27
27
  return ret;
@@ -1,5 +1,7 @@
1
+ import { constant, noop } from 'ut2';
2
+
1
3
  var objectKeys = Object.keys;
2
- var createObjectURL = URL.createObjectURL;
3
- var revokeObjectURL = URL.revokeObjectURL;
4
+ var createObjectURL = typeof URL !== 'undefined' ? URL.createObjectURL : constant('');
5
+ var revokeObjectURL = typeof URL !== 'undefined' ? URL.revokeObjectURL : noop;
4
6
 
5
7
  export { createObjectURL, objectKeys, revokeObjectURL };
package/lib/VERSION.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var VERSION = "4.20.4";
3
+ var VERSION = "4.20.6";
4
4
  var VERSION$1 = VERSION;
5
5
 
6
6
  module.exports = VERSION$1;
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ var ut2 = require('ut2');
4
+
3
5
  function bytesToSize(bytes, options) {
4
6
  if (options === void 0) { options = {}; }
5
7
  var _a = options.spaceMark, spaceMark = _a === void 0 ? ' ' : _a, _b = options.precision, precision = _b === void 0 ? 2 : _b;
6
8
  var numBytes = typeof bytes !== 'number' ? Number(bytes) : bytes;
7
- if (numBytes === 0 || isNaN(numBytes))
9
+ if (numBytes === 0 || ut2.isNaN(numBytes))
8
10
  return "0".concat(spaceMark, "B");
9
11
  var k = 1024;
10
12
  var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
package/lib/index.js CHANGED
@@ -65,7 +65,7 @@ var findTreeSelect = require('./findTreeSelect.js');
65
65
  var config = require('./utils/config.js');
66
66
  var VERSION = require('./VERSION.js');
67
67
 
68
- exports.version = "4.20.4";
68
+ exports.version = "4.20.6";
69
69
 
70
70
  exports.isMobile = isMobile;
71
71
  exports.isTelephone = isTelephone;
@@ -19,7 +19,7 @@ function isValidNumber(value, strict) {
19
19
  ret = Number(value);
20
20
  }
21
21
  }
22
- return typeof ret === 'number' && !Number.isNaN(ret);
22
+ return typeof ret === 'number' && !ut2.isNaN(ret);
23
23
  }
24
24
 
25
25
  module.exports = isValidNumber;
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var ut2 = require('ut2');
3
4
  var math_util = require('./utils/math.util.js');
4
5
  var devWarn = require('./utils/devWarn.js');
5
6
 
@@ -79,7 +80,7 @@ function numberToChinese(num, options) {
79
80
  if (options === void 0) { options = {}; }
80
81
  var _a = options.big5, big5 = _a === void 0 ? false : _a, _b = options.unit, unit = _b === void 0 ? true : _b, _c = options.zero, zero = _c === void 0 ? '' : _c, _d = options.negative, negative = _d === void 0 ? '负' : _d, _e = options.unitConfig, unitConfig = _e === void 0 ? {} : _e;
81
82
  var _f = options.decimal, decimal = _f === void 0 ? '' : _f;
82
- if (typeof num !== 'number' || isNaN(num)) {
83
+ if (typeof num !== 'number' || ut2.isNaN(num)) {
83
84
  devWarn("\u53C2\u6570\u9519\u8BEF ".concat(num, "\uFF0C\u8BF7\u4F20\u5165\u6570\u5B57"));
84
85
  return '';
85
86
  }
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var ut2 = require('ut2');
4
+
3
5
  var numberChars = '0123456789';
4
6
  var letterChars = 'abcdefghijklmnopqrstuvwxyz';
5
7
  var defaultChars = numberChars + letterChars + letterChars.toUpperCase();
@@ -14,7 +16,7 @@ function internalRandomString(len, optionalChars, prefix) {
14
16
  function randomString(len, optionalChars) {
15
17
  if (len === void 0) { len = 0; }
16
18
  var realChars = typeof optionalChars === 'string' && optionalChars ? optionalChars : defaultChars;
17
- return internalRandomString(len, realChars);
19
+ return internalRandomString(ut2.toNumber(len), realChars);
18
20
  }
19
21
 
20
22
  module.exports = randomString;
@@ -10,7 +10,7 @@ function transformEffectiveNumber(value) {
10
10
  if (ret === '') {
11
11
  ret = Number(ret);
12
12
  }
13
- else if (Number.isNaN(Number(ret))) {
13
+ else if (ut2.isNaN(Number(ret))) {
14
14
  ret = Number.NaN;
15
15
  }
16
16
  }
@@ -23,7 +23,7 @@ function transformEffectiveNumber(value) {
23
23
  else {
24
24
  ret = value;
25
25
  }
26
- if (Number.isNaN(ret)) {
26
+ if (ut2.isNaN(ret)) {
27
27
  return Number.NaN;
28
28
  }
29
29
  return ret;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var ut2 = require('ut2');
4
+
3
5
  exports.objectKeys = Object.keys;
4
- exports.createObjectURL = URL.createObjectURL;
5
- exports.revokeObjectURL = URL.revokeObjectURL;
6
+ exports.createObjectURL = typeof URL !== 'undefined' ? URL.createObjectURL : ut2.constant('');
7
+ exports.revokeObjectURL = typeof URL !== 'undefined' ? URL.revokeObjectURL : ut2.noop;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "4.20.4",
3
+ "version": "4.20.6",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",
@@ -23,7 +23,8 @@
23
23
  "lint:fix": "eslint src --ext .ts --fix",
24
24
  "commit": "cz",
25
25
  "prepublishOnly": "npm test && npm run build",
26
- "tsc": "tsc --noEmit"
26
+ "tsc": "tsc --noEmit",
27
+ "prepare": "husky install"
27
28
  },
28
29
  "repository": {
29
30
  "type": "git",
@@ -77,16 +78,12 @@
77
78
  "prettier": "^2.8.8",
78
79
  "rollup": "^3.28.1",
79
80
  "typescript": "^5.2.2",
80
- "yorkie": "^2.0.0"
81
+ "husky": "^8.0.0"
81
82
  },
82
83
  "lint-staged": {
83
84
  "**/*.ts": "eslint",
84
85
  "**/*.{js,ts,md}": "prettier --write"
85
86
  },
86
- "gitHooks": {
87
- "pre-commit": "lint-staged",
88
- "commit-msg": "npx --no -- commitlint --edit \"$1\""
89
- },
90
87
  "config": {
91
88
  "commitizen": {
92
89
  "path": "./node_modules/cz-conventional-changelog"
@@ -94,6 +91,6 @@
94
91
  },
95
92
  "dependencies": {
96
93
  "tslib": "^2.6.2",
97
- "ut2": "^1.4.8"
94
+ "ut2": "^1.4.9"
98
95
  }
99
96
  }