util-helpers 4.19.3 → 4.19.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/README.md +2 -4
- package/dist/util-helpers.js +36 -32
- 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/formatMoney.js +1 -0
- package/esm/index.js +1 -1
- package/esm/replaceChar.js +1 -0
- package/lib/VERSION.js +1 -1
- package/lib/formatMoney.js +1 -0
- package/lib/index.js +1 -1
- package/lib/replaceChar.js +1 -0
- package/package.json +4 -4
- package/types/download.d.ts +1 -0
- package/types/formatMoney.d.ts +1 -1
- package/types/replaceChar.d.ts +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# util-helpers
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
|
|
5
|
-
[util-helpers](https://doly-dev.github.io/util-helpers/index.html) 是一个基于业务场景的工具方法库。
|
|
3
|
+
一个基于业务场景的工具方法库。[点击查看在线文档](https://doly-dev.github.io/util-helpers/index.html)。
|
|
6
4
|
|
|
7
|
-
[
|
|
5
|
+
[![npm][npm]][npm-url] [](https://github.com/doly-dev/util-helpers/actions/workflows/ci.yml) [](https://codecov.io/gh/doly-dev/util-helpers)  
|
|
8
6
|
|
|
9
7
|
## 使用
|
|
10
8
|
|
package/dist/util-helpers.js
CHANGED
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
18
18
|
var functionToString = Function.prototype.toString;
|
|
19
19
|
functionToString.call(Object);
|
|
20
|
+
var symbolProto = Symbol ? Symbol.prototype : undefined;
|
|
21
|
+
symbolProto ? symbolProto.valueOf : undefined;
|
|
22
|
+
symbolProto ? symbolProto.toString : undefined;
|
|
23
|
+
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
20
24
|
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
21
25
|
var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991;
|
|
22
26
|
var blobExisted = typeof Blob !== 'undefined';
|
|
@@ -59,11 +63,11 @@
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
function getRawTag(value) {
|
|
62
|
-
var isOwn = hasOwnProperty.call(value,
|
|
63
|
-
var tag = value[
|
|
66
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag);
|
|
67
|
+
var tag = value[symToStringTag];
|
|
64
68
|
var unmasked = false;
|
|
65
69
|
try {
|
|
66
|
-
value[
|
|
70
|
+
value[symToStringTag] = undefined;
|
|
67
71
|
unmasked = true;
|
|
68
72
|
}
|
|
69
73
|
catch (e) {
|
|
@@ -71,18 +75,16 @@
|
|
|
71
75
|
var result = objectToString.call(value);
|
|
72
76
|
if (unmasked) {
|
|
73
77
|
if (isOwn) {
|
|
74
|
-
value[
|
|
78
|
+
value[symToStringTag] = tag;
|
|
75
79
|
}
|
|
76
80
|
else {
|
|
77
|
-
delete value[
|
|
81
|
+
delete value[symToStringTag];
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
return result;
|
|
81
85
|
}
|
|
82
86
|
function _getTag(value) {
|
|
83
|
-
return
|
|
84
|
-
? getRawTag(value)
|
|
85
|
-
: objectToString.call(value);
|
|
87
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString.call(value);
|
|
86
88
|
}
|
|
87
89
|
var getTag = _getTag;
|
|
88
90
|
if ((dataViewExisted && objectToString.call(new DataView(new ArrayBuffer(1))) !== dataViewTag) ||
|
|
@@ -167,10 +169,6 @@
|
|
|
167
169
|
isType((function () { return arguments; })(), argType);
|
|
168
170
|
var numberIsFinite = Number.isFinite;
|
|
169
171
|
|
|
170
|
-
function isFinite$1(value) {
|
|
171
|
-
return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
172
|
function baseToString(value) {
|
|
175
173
|
if (typeof value === 'string') {
|
|
176
174
|
return value;
|
|
@@ -188,28 +186,14 @@
|
|
|
188
186
|
return value == null ? '' : baseToString(value);
|
|
189
187
|
}
|
|
190
188
|
|
|
191
|
-
function decimalAdjust(type, value, precision) {
|
|
192
|
-
if (precision === void 0) { precision = 0; }
|
|
193
|
-
var func = Math[type];
|
|
194
|
-
value = toNumber(value);
|
|
195
|
-
precision = Math.min(toInteger(precision), 292);
|
|
196
|
-
if (precision === 0 || !isFinite$1(value)) {
|
|
197
|
-
return func(value);
|
|
198
|
-
}
|
|
199
|
-
var pair = toString(value).split('e');
|
|
200
|
-
value = func(+(pair[0] + 'e' + (pair[1] ? +pair[1] + precision : precision)));
|
|
201
|
-
pair = toString(value).split('e');
|
|
202
|
-
return +(pair[0] + 'e' + (pair[1] ? +pair[1] - precision : -precision));
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function round(number, precision) {
|
|
206
|
-
return decimalAdjust('round', number, precision);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
189
|
function isBlob(value) {
|
|
210
190
|
return (blobExisted && value instanceof Blob) || isType(value, ['Blob', 'File']);
|
|
211
191
|
}
|
|
212
192
|
|
|
193
|
+
function isFinite$1(value) {
|
|
194
|
+
return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
|
|
195
|
+
}
|
|
196
|
+
|
|
213
197
|
function isNumber(value) {
|
|
214
198
|
return typeof value === 'number' || (isObjectLike(value) && isType(value, 'Number'));
|
|
215
199
|
}
|
|
@@ -226,6 +210,24 @@
|
|
|
226
210
|
return typeof value === 'string' || (isObjectLike(value) && isType(value, 'String'));
|
|
227
211
|
}
|
|
228
212
|
|
|
213
|
+
function decimalAdjust(type, value, precision) {
|
|
214
|
+
if (precision === void 0) { precision = 0; }
|
|
215
|
+
var func = Math[type];
|
|
216
|
+
value = toNumber(value);
|
|
217
|
+
precision = Math.min(toInteger(precision), 292);
|
|
218
|
+
if (precision === 0 || !isFinite$1(value)) {
|
|
219
|
+
return func(value);
|
|
220
|
+
}
|
|
221
|
+
var pair = toString(value).split('e');
|
|
222
|
+
value = func(+(pair[0] + 'e' + (pair[1] ? +pair[1] + precision : precision)));
|
|
223
|
+
pair = toString(value).split('e');
|
|
224
|
+
return +(pair[0] + 'e' + (pair[1] ? +pair[1] - precision : -precision));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function round(number, precision) {
|
|
228
|
+
return decimalAdjust('round', number, precision);
|
|
229
|
+
}
|
|
230
|
+
|
|
229
231
|
function sleep(ms) {
|
|
230
232
|
if (ms === void 0) { ms = 1000; }
|
|
231
233
|
return new Promise(function (resolve) {
|
|
@@ -893,6 +895,7 @@
|
|
|
893
895
|
return decimal + ret;
|
|
894
896
|
}
|
|
895
897
|
var formatMoney = function (num, options) {
|
|
898
|
+
if (num === void 0) { num = ''; }
|
|
896
899
|
if (options === void 0) { options = {}; }
|
|
897
900
|
var _a = options.precision, precision = _a === void 0 ? 2 : _a, symbol = options.symbol, _b = options.thousand, thousand = _b === void 0 ? ',' : _b, _c = options.decimal, decimal = _c === void 0 ? '.' : _c;
|
|
898
901
|
if (!checkNumber(num)) {
|
|
@@ -928,6 +931,7 @@
|
|
|
928
931
|
}
|
|
929
932
|
|
|
930
933
|
function replaceChar(str, options) {
|
|
934
|
+
if (str === void 0) { str = ''; }
|
|
931
935
|
if (options === void 0) { options = {}; }
|
|
932
936
|
var _a = options.char, char = _a === void 0 ? '*' : _a, exclude = options.exclude;
|
|
933
937
|
var _b = options.start, start = _b === void 0 ? 3 : _b, _c = options.end, end = _c === void 0 ? -4 : _c, repeat = options.repeat;
|
|
@@ -1820,9 +1824,9 @@
|
|
|
1820
1824
|
return internalFindTreeSelect(tree, predicate, childrenField);
|
|
1821
1825
|
}
|
|
1822
1826
|
|
|
1823
|
-
var VERSION = "4.19.
|
|
1827
|
+
var VERSION = "4.19.4";
|
|
1824
1828
|
|
|
1825
|
-
var version = "4.19.
|
|
1829
|
+
var version = "4.19.4";
|
|
1826
1830
|
|
|
1827
1831
|
exports.VERSION = VERSION;
|
|
1828
1832
|
exports.ajax = ajax;
|