util-helpers 5.7.4 → 5.7.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/README.md +2 -1
- package/dist/util-helpers.js +98 -91
- 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/loadScript.js +30 -23
- package/lib/VERSION.js +1 -1
- package/lib/loadScript.js +29 -22
- package/package.json +25 -24
- package/types/filterTree.d.ts +1 -1
- package/types/findTreeNode.d.ts +1 -1
- package/types/findTreeNodes.d.ts +1 -1
- package/types/findTreeSelect.d.ts +1 -1
- package/types/getMimeType.d.ts +1 -0
- package/types/isEmail.d.ts +7 -1
- package/types/listToTree.d.ts +1 -1
- package/types/loadScript.d.ts +15 -2
- package/types/transformFieldNames.d.ts +3 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
一个基于业务场景的工具方法库。[点击查看在线文档](https://doly-dev.github.io/util-helpers/index.html)。
|
|
4
4
|
|
|
5
|
-
[![npm][npm]][npm-url] [](https://github.com/doly-dev/util-helpers/actions/workflows/ci.yml) [](https://codecov.io/gh/doly-dev/util-helpers) ](https://github.com/doly-dev/util-helpers/actions/workflows/ci.yml) [](https://codecov.io/gh/doly-dev/util-helpers)  
|
|
6
6
|
|
|
7
7
|
## 使用
|
|
8
8
|
|
|
@@ -137,6 +137,7 @@ formatBankCard('6228480402564890018', { spaceMark: '-' }); // 6228-4804-0256-489
|
|
|
137
137
|
- [uuid] - 生成通用唯一识别码(Universally Unique Identifier)
|
|
138
138
|
- [JSZip] - 创建、读取和编辑 zip 文件
|
|
139
139
|
- [ua-parser-js] - 用于从用户代理数据中检测浏览器、引擎、操作系统、CPU 和设备类型/型号
|
|
140
|
+
<!-- - [semver](https://www.npmjs.com/package/semver) - npm 语义版本控制。 -->
|
|
140
141
|
|
|
141
142
|
[ut2]: https://www.npmjs.com/package/ut2
|
|
142
143
|
[lodash]: https://www.npmjs.com/package/lodash
|
package/dist/util-helpers.js
CHANGED
|
@@ -205,74 +205,6 @@
|
|
|
205
205
|
return isNil(value) ? '' : baseToString(value);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
var blobExisted = typeof Blob !== stringUndefined;
|
|
209
|
-
function isBlob(value) {
|
|
210
|
-
if (blobExisted && value instanceof Blob) {
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
return getTag(value) === blobTag;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
var objectCtorString = functionProtoToString.call(Object);
|
|
217
|
-
function isPlainObject(value) {
|
|
218
|
-
if (!isObjectLike(value) || getTag(value) !== objectTag) {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
var proto = objectGetPrototypeOf(Object(value));
|
|
222
|
-
if (proto === null) {
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
var Ctor = objectProtoHasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
226
|
-
return typeof Ctor === 'function' && Ctor instanceof Ctor && functionProtoToString.call(Ctor) === objectCtorString;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
var fileExisted = typeof File !== stringUndefined;
|
|
230
|
-
function isFile(value) {
|
|
231
|
-
if (fileExisted && value instanceof File) {
|
|
232
|
-
return true;
|
|
233
|
-
}
|
|
234
|
-
return getTag(value) === fileTag;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
var freeGlobalThis = globalThisExisted && globalThis.Object === Object && globalThis;
|
|
238
|
-
var freeGlobal = globalExisted && global.Object === Object && global;
|
|
239
|
-
var freeSelf = selfExisted && self.Object === Object && self;
|
|
240
|
-
var root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')();
|
|
241
|
-
|
|
242
|
-
function isFinite$1(value) {
|
|
243
|
-
return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function isNaN(value) {
|
|
247
|
-
return isNumber(value) && root.isNaN(value);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function isPromiseLike(value) {
|
|
251
|
-
return isObject(value) && typeof value.then === 'function';
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function isString(value) {
|
|
255
|
-
return typeof value === 'string' || getTag(value) === stringTag;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function decimalAdjust(type, value, precision) {
|
|
259
|
-
if (precision === void 0) { precision = 0; }
|
|
260
|
-
var func = Math[type];
|
|
261
|
-
value = toNumber(value);
|
|
262
|
-
precision = mathMin(toInteger(precision), 292);
|
|
263
|
-
if (precision === 0 || !isFinite$1(value)) {
|
|
264
|
-
return func(value);
|
|
265
|
-
}
|
|
266
|
-
var pair = toString(value).split('e');
|
|
267
|
-
value = func(+(pair[0] + 'e' + (pair[1] ? +pair[1] + precision : precision)));
|
|
268
|
-
pair = toString(value).split('e');
|
|
269
|
-
return +(pair[0] + 'e' + (pair[1] ? +pair[1] - precision : -precision));
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function round(number, precision) {
|
|
273
|
-
return decimalAdjust('round', number, precision);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
208
|
/******************************************************************************
|
|
277
209
|
Copyright (c) Microsoft Corporation.
|
|
278
210
|
|
|
@@ -397,6 +329,74 @@
|
|
|
397
329
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
398
330
|
};
|
|
399
331
|
|
|
332
|
+
var blobExisted = typeof Blob !== stringUndefined;
|
|
333
|
+
function isBlob(value) {
|
|
334
|
+
if (blobExisted && value instanceof Blob) {
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
return getTag(value) === blobTag;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
var objectCtorString = functionProtoToString.call(Object);
|
|
341
|
+
function isPlainObject(value) {
|
|
342
|
+
if (!isObjectLike(value) || getTag(value) !== objectTag) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
var proto = objectGetPrototypeOf(Object(value));
|
|
346
|
+
if (proto === null) {
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
var Ctor = objectProtoHasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
350
|
+
return typeof Ctor === 'function' && Ctor instanceof Ctor && functionProtoToString.call(Ctor) === objectCtorString;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
var fileExisted = typeof File !== stringUndefined;
|
|
354
|
+
function isFile(value) {
|
|
355
|
+
if (fileExisted && value instanceof File) {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
return getTag(value) === fileTag;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
var freeGlobalThis = globalThisExisted && globalThis.Object === Object && globalThis;
|
|
362
|
+
var freeGlobal = globalExisted && global.Object === Object && global;
|
|
363
|
+
var freeSelf = selfExisted && self.Object === Object && self;
|
|
364
|
+
var root = freeGlobalThis || freeGlobal || freeSelf || Function('return this')();
|
|
365
|
+
|
|
366
|
+
function isFinite$1(value) {
|
|
367
|
+
return numberIsFinite ? numberIsFinite(value) : typeof value === 'number' && root.isFinite(value);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function isNaN(value) {
|
|
371
|
+
return isNumber(value) && root.isNaN(value);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function isPromiseLike(value) {
|
|
375
|
+
return isObject(value) && typeof value.then === 'function';
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function isString(value) {
|
|
379
|
+
return typeof value === 'string' || getTag(value) === stringTag;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function decimalAdjust(type, value, precision) {
|
|
383
|
+
if (precision === void 0) { precision = 0; }
|
|
384
|
+
var func = Math[type];
|
|
385
|
+
value = toNumber(value);
|
|
386
|
+
precision = mathMin(toInteger(precision), 292);
|
|
387
|
+
if (precision === 0 || !isFinite$1(value)) {
|
|
388
|
+
return func(value);
|
|
389
|
+
}
|
|
390
|
+
var pair = toString(value).split('e');
|
|
391
|
+
value = func(+(pair[0] + 'e' + (pair[1] ? +pair[1] + precision : precision)));
|
|
392
|
+
pair = toString(value).split('e');
|
|
393
|
+
return +(pair[0] + 'e' + (pair[1] ? +pair[1] - precision : -precision));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function round(number, precision) {
|
|
397
|
+
return decimalAdjust('round', number, precision);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
400
|
function constant(value) {
|
|
401
401
|
return function () {
|
|
402
402
|
return value;
|
|
@@ -1811,16 +1811,20 @@
|
|
|
1811
1811
|
return style;
|
|
1812
1812
|
}
|
|
1813
1813
|
|
|
1814
|
-
function
|
|
1814
|
+
var loadScript = function (_src, options) {
|
|
1815
|
+
var finalOptions;
|
|
1816
|
+
if (typeof _src === 'object') {
|
|
1817
|
+
finalOptions = _src;
|
|
1818
|
+
}
|
|
1819
|
+
else if (typeof _src === 'string') {
|
|
1820
|
+
finalOptions = __assign({ src: _src }, options);
|
|
1821
|
+
}
|
|
1815
1822
|
return new Promise(function (resolve, reject) {
|
|
1816
1823
|
var container = document.head || document.getElementsByTagName('head')[0] || document.body;
|
|
1817
1824
|
var script = document.createElement('script');
|
|
1818
|
-
var _a =
|
|
1819
|
-
var props = __assign(
|
|
1825
|
+
var _a = finalOptions || {}, src = _a.src, attrs = _a.attrs, _b = _a.destroyOnError, destroyOnError = _b === void 0 ? true : _b, onload = _a.onload, onerror = _a.onerror, restOptions = __rest(_a, ["src", "attrs", "destroyOnError", "onload", "onerror"]);
|
|
1826
|
+
var props = __assign({ async: true, type: 'text/javascript' }, restOptions);
|
|
1820
1827
|
for (var key in props) {
|
|
1821
|
-
if (key === 'onload' || key === 'onerror') {
|
|
1822
|
-
continue;
|
|
1823
|
-
}
|
|
1824
1828
|
script[key] = props[key];
|
|
1825
1829
|
}
|
|
1826
1830
|
if (typeof attrs === 'object') {
|
|
@@ -1828,24 +1832,27 @@
|
|
|
1828
1832
|
script.setAttribute(key, attrs[key]);
|
|
1829
1833
|
});
|
|
1830
1834
|
}
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
}
|
|
1835
|
+
if (src) {
|
|
1836
|
+
script.src = src;
|
|
1837
|
+
script.onload = function (ev) {
|
|
1838
|
+
onload === null || onload === void 0 ? void 0 : onload.call(this, ev);
|
|
1839
|
+
resolve(script);
|
|
1840
|
+
};
|
|
1841
|
+
script.onerror = function (ev) {
|
|
1842
|
+
this.onerror = this.onload = null;
|
|
1843
|
+
onerror === null || onerror === void 0 ? void 0 : onerror.call(this, ev);
|
|
1844
|
+
if (destroyOnError) {
|
|
1845
|
+
container.removeChild(script);
|
|
1846
|
+
}
|
|
1847
|
+
reject(new URIError('Failed to load ' + this.src));
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1846
1850
|
container.appendChild(script);
|
|
1851
|
+
if (!src) {
|
|
1852
|
+
resolve(script);
|
|
1853
|
+
}
|
|
1847
1854
|
});
|
|
1848
|
-
}
|
|
1855
|
+
};
|
|
1849
1856
|
|
|
1850
1857
|
function calculateCursorPosition(prevPos, prevCtrlValue, rawValue, ctrlValue, options) {
|
|
1851
1858
|
if (options === void 0) { options = {}; }
|
|
@@ -2192,7 +2199,7 @@
|
|
|
2192
2199
|
return internalFindTreeSelect(tree, predicate, childrenField);
|
|
2193
2200
|
}
|
|
2194
2201
|
|
|
2195
|
-
var VERSION = "5.7.
|
|
2202
|
+
var VERSION = "5.7.6";
|
|
2196
2203
|
|
|
2197
2204
|
/**
|
|
2198
2205
|
* 事件触发器,支持浏览器端和 node 端。
|