util-helpers 4.12.3 → 4.12.4
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 +1 -1
- 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/utils/config.js +1 -1
- package/esm/utils/math.util.js +0 -32
- package/lib/utils/config.js +1 -1
- package/lib/utils/math.util.js +0 -34
- package/package.json +1 -1
- package/types/src/utils/math.util.d.ts +0 -8
package/esm/utils/math.util.js
CHANGED
|
@@ -7,38 +7,6 @@
|
|
|
7
7
|
import { MAX_SAFE_INTEGER, MIN_SAFE_INTEGER } from './constants';
|
|
8
8
|
import devWarn from './devWarn';
|
|
9
9
|
import { isNumber, isString, isSymbol } from './type';
|
|
10
|
-
/**
|
|
11
|
-
* 值是否为有效的数值
|
|
12
|
-
*
|
|
13
|
-
* @deprecated 已废弃
|
|
14
|
-
* @param {*} value 待检测的值
|
|
15
|
-
* @returns {boolean} 是否为有效的数值
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export function isEffectiveNumeric() {
|
|
19
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
20
|
-
|
|
21
|
-
if (isNumber(value) && !isNaN(value)) {
|
|
22
|
-
return true;
|
|
23
|
-
} // 避免空字符串 或 带空格的字符串
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (isString(value)) {
|
|
27
|
-
var fmtStrValue = value.trim(); // 带空格的字符串也不转换数字
|
|
28
|
-
// Number(' ') => 0
|
|
29
|
-
|
|
30
|
-
if (fmtStrValue === value) {
|
|
31
|
-
var numValue = fmtStrValue ? Number(fmtStrValue) : NaN;
|
|
32
|
-
|
|
33
|
-
if (!isNaN(numValue)) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
devWarn("".concat(value, " is not a valid number."));
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
10
|
/**
|
|
43
11
|
* 将值转换为有效数值
|
|
44
12
|
*
|
package/lib/utils/config.js
CHANGED
package/lib/utils/math.util.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isEffectiveNumeric = isEffectiveNumeric;
|
|
7
6
|
exports.transformEffectiveNumber = transformEffectiveNumber;
|
|
8
7
|
exports.isScientificNumber = isScientificNumber;
|
|
9
8
|
exports.strip = strip;
|
|
@@ -28,45 +27,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
28
27
|
* 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
/**
|
|
32
|
-
* 值是否为有效的数值
|
|
33
|
-
*
|
|
34
|
-
* @deprecated 已废弃
|
|
35
|
-
* @param {*} value 待检测的值
|
|
36
|
-
* @returns {boolean} 是否为有效的数值
|
|
37
|
-
*/
|
|
38
|
-
function isEffectiveNumeric() {
|
|
39
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
40
|
-
|
|
41
|
-
if ((0, _type.isNumber)(value) && !isNaN(value)) {
|
|
42
|
-
return true;
|
|
43
|
-
} // 避免空字符串 或 带空格的字符串
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if ((0, _type.isString)(value)) {
|
|
47
|
-
var fmtStrValue = value.trim(); // 带空格的字符串也不转换数字
|
|
48
|
-
// Number(' ') => 0
|
|
49
|
-
|
|
50
|
-
if (fmtStrValue === value) {
|
|
51
|
-
var numValue = fmtStrValue ? Number(fmtStrValue) : NaN;
|
|
52
|
-
|
|
53
|
-
if (!isNaN(numValue)) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
(0, _devWarn["default"])("".concat(value, " is not a valid number."));
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
30
|
/**
|
|
63
31
|
* 将值转换为有效数值
|
|
64
32
|
*
|
|
65
33
|
* @param {*} value 要转换的值
|
|
66
34
|
* @returns {number|string} 有效数值
|
|
67
35
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
36
|
function transformEffectiveNumber(value) {
|
|
71
37
|
/** @type {string|number|undefined} */
|
|
72
38
|
var ret;
|
package/package.json
CHANGED