util-helpers 4.20.3 → 4.20.5

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.3";
1
+ var VERSION = "4.20.5";
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.3";
66
+ var version = "4.20.5";
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 };
@@ -10,17 +10,22 @@ function getBlob(img, ajaxOptions) {
10
10
  resolve(img);
11
11
  }
12
12
  else {
13
- ajax(img, __assign({ responseType: 'blob', headers: { 'sec-fetch-site': 'none' } }, ajaxOptions))
13
+ ajax(img, __assign({ responseType: 'blob' }, ajaxOptions))
14
14
  .then(function (ev) {
15
15
  var responseStatus = ev.target.status;
16
16
  if (SuccessResponseStatus.indexOf(responseStatus) !== -1) {
17
17
  resolve(ev.target.response);
18
18
  }
19
19
  else {
20
- reject(new Error("[loadImageWithBlob] The image does not support get requests, responseStatus ".concat(responseStatus, ", '").concat(img, "'.")));
20
+ var err = new Error("[loadImageWithBlob] The image does not support get requests, responseStatus ".concat(responseStatus, ", '").concat(img, "'."));
21
+ console.error(err);
22
+ reject(err);
21
23
  }
22
24
  })
23
- .catch(reject);
25
+ .catch(function (err) {
26
+ console.error(new Error("[loadImageWithBlob] Failed to request image. ".concat(err)));
27
+ reject(err);
28
+ });
24
29
  }
25
30
  });
26
31
  }
@@ -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;
package/lib/VERSION.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var VERSION = "4.20.3";
3
+ var VERSION = "4.20.5";
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.3";
68
+ exports.version = "4.20.5";
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;
@@ -12,17 +12,22 @@ function getBlob(img, ajaxOptions) {
12
12
  resolve(img);
13
13
  }
14
14
  else {
15
- ajax(img, tslib.__assign({ responseType: 'blob', headers: { 'sec-fetch-site': 'none' } }, ajaxOptions))
15
+ ajax(img, tslib.__assign({ responseType: 'blob' }, ajaxOptions))
16
16
  .then(function (ev) {
17
17
  var responseStatus = ev.target.status;
18
18
  if (SuccessResponseStatus.indexOf(responseStatus) !== -1) {
19
19
  resolve(ev.target.response);
20
20
  }
21
21
  else {
22
- reject(new Error("[loadImageWithBlob] The image does not support get requests, responseStatus ".concat(responseStatus, ", '").concat(img, "'.")));
22
+ var err = new Error("[loadImageWithBlob] The image does not support get requests, responseStatus ".concat(responseStatus, ", '").concat(img, "'."));
23
+ console.error(err);
24
+ reject(err);
23
25
  }
24
26
  })
25
- .catch(reject);
27
+ .catch(function (err) {
28
+ console.error(new Error("[loadImageWithBlob] Failed to request image. ".concat(err)));
29
+ reject(err);
30
+ });
26
31
  }
27
32
  });
28
33
  }
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "util-helpers",
3
- "version": "4.20.3",
3
+ "version": "4.20.5",
4
4
  "description": "一个基于业务场景的工具方法库",
5
5
  "main": "lib/index.js",
6
6
  "module": "esm/index.js",