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/dist/util-helpers.js +22 -17
- package/dist/util-helpers.js.map +1 -1
- package/dist/util-helpers.min.js +1 -1
- package/dist/util-helpers.min.js.map +1 -1
- package/esm/VERSION.js +1 -1
- package/esm/bytesToSize.js +2 -0
- package/esm/index.js +1 -1
- package/esm/isValidNumber.js +2 -2
- package/esm/loadImageWithBlob.js +8 -3
- package/esm/numberToChinese.js +1 -0
- package/esm/randomString.js +3 -1
- package/esm/utils/math.util.js +3 -3
- package/lib/VERSION.js +1 -1
- package/lib/bytesToSize.js +3 -1
- package/lib/index.js +1 -1
- package/lib/isValidNumber.js +1 -1
- package/lib/loadImageWithBlob.js +8 -3
- package/lib/numberToChinese.js +2 -1
- package/lib/randomString.js +3 -1
- package/lib/utils/math.util.js +2 -2
- package/package.json +1 -1
package/esm/VERSION.js
CHANGED
package/esm/bytesToSize.js
CHANGED
package/esm/index.js
CHANGED
package/esm/isValidNumber.js
CHANGED
|
@@ -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' && !
|
|
20
|
+
return typeof ret === 'number' && !isNaN(ret);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export { isValidNumber as default };
|
package/esm/loadImageWithBlob.js
CHANGED
|
@@ -10,17 +10,22 @@ function getBlob(img, ajaxOptions) {
|
|
|
10
10
|
resolve(img);
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
ajax(img, __assign({ responseType: 'blob'
|
|
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
|
-
|
|
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(
|
|
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
|
}
|
package/esm/numberToChinese.js
CHANGED
package/esm/randomString.js
CHANGED
|
@@ -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 };
|
package/esm/utils/math.util.js
CHANGED
|
@@ -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 (
|
|
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 (
|
|
24
|
+
if (isNaN(ret)) {
|
|
25
25
|
return Number.NaN;
|
|
26
26
|
}
|
|
27
27
|
return ret;
|
package/lib/VERSION.js
CHANGED
package/lib/bytesToSize.js
CHANGED
|
@@ -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.
|
|
68
|
+
exports.version = "4.20.5";
|
|
69
69
|
|
|
70
70
|
exports.isMobile = isMobile;
|
|
71
71
|
exports.isTelephone = isTelephone;
|
package/lib/isValidNumber.js
CHANGED
package/lib/loadImageWithBlob.js
CHANGED
|
@@ -12,17 +12,22 @@ function getBlob(img, ajaxOptions) {
|
|
|
12
12
|
resolve(img);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
-
ajax(img, tslib.__assign({ responseType: 'blob'
|
|
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
|
-
|
|
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(
|
|
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
|
}
|
package/lib/numberToChinese.js
CHANGED
|
@@ -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
|
}
|
package/lib/randomString.js
CHANGED
|
@@ -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;
|
package/lib/utils/math.util.js
CHANGED
|
@@ -10,7 +10,7 @@ function transformEffectiveNumber(value) {
|
|
|
10
10
|
if (ret === '') {
|
|
11
11
|
ret = Number(ret);
|
|
12
12
|
}
|
|
13
|
-
else if (
|
|
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 (
|
|
26
|
+
if (ut2.isNaN(ret)) {
|
|
27
27
|
return Number.NaN;
|
|
28
28
|
}
|
|
29
29
|
return ret;
|