mazey 3.6.6 → 3.7.0
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 +7 -7
- package/lib/index.cjs.js +484 -108
- package/lib/index.d.ts +111 -47
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +481 -109
- package/lib/mazey.min.js +2 -2
- package/package.json +2 -1
- package/scripts/github-helper.js +28 -3
package/lib/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* mazey v3.
|
|
2
|
+
* mazey v3.7.0
|
|
3
3
|
* (c) 2018-2023 Mazey Chu
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -1125,7 +1125,7 @@ var isConstructor = !construct || fails(function () {
|
|
|
1125
1125
|
}) ? isConstructorLegacy : isConstructorModern;
|
|
1126
1126
|
|
|
1127
1127
|
var SPECIES$6 = wellKnownSymbol('species');
|
|
1128
|
-
var $Array$
|
|
1128
|
+
var $Array$3 = Array;
|
|
1129
1129
|
|
|
1130
1130
|
// a part of `ArraySpeciesCreate` abstract operation
|
|
1131
1131
|
// https://tc39.es/ecma262/#sec-arrayspeciescreate
|
|
@@ -1134,12 +1134,12 @@ var arraySpeciesConstructor = function (originalArray) {
|
|
|
1134
1134
|
if (isArray(originalArray)) {
|
|
1135
1135
|
C = originalArray.constructor;
|
|
1136
1136
|
// cross-realm fallback
|
|
1137
|
-
if (isConstructor(C) && (C === $Array$
|
|
1137
|
+
if (isConstructor(C) && (C === $Array$3 || isArray(C.prototype))) C = undefined;
|
|
1138
1138
|
else if (isObject(C)) {
|
|
1139
1139
|
C = C[SPECIES$6];
|
|
1140
1140
|
if (C === null) C = undefined;
|
|
1141
1141
|
}
|
|
1142
|
-
} return C === undefined ? $Array$
|
|
1142
|
+
} return C === undefined ? $Array$3 : C;
|
|
1143
1143
|
};
|
|
1144
1144
|
|
|
1145
1145
|
// `ArraySpeciesCreate` abstract operation
|
|
@@ -1401,7 +1401,7 @@ var NativeRegExp = global_1.RegExp;
|
|
|
1401
1401
|
var RegExpPrototype$2 = NativeRegExp.prototype;
|
|
1402
1402
|
var SyntaxError = global_1.SyntaxError;
|
|
1403
1403
|
var exec$1 = functionUncurryThis(RegExpPrototype$2.exec);
|
|
1404
|
-
var charAt$
|
|
1404
|
+
var charAt$6 = functionUncurryThis(''.charAt);
|
|
1405
1405
|
var replace$3 = functionUncurryThis(''.replace);
|
|
1406
1406
|
var stringIndexOf$2 = functionUncurryThis(''.indexOf);
|
|
1407
1407
|
var stringSlice$7 = functionUncurryThis(''.slice);
|
|
@@ -1430,9 +1430,9 @@ var handleDotAll = function (string) {
|
|
|
1430
1430
|
var brackets = false;
|
|
1431
1431
|
var chr;
|
|
1432
1432
|
for (; index <= length; index++) {
|
|
1433
|
-
chr = charAt$
|
|
1433
|
+
chr = charAt$6(string, index);
|
|
1434
1434
|
if (chr === '\\') {
|
|
1435
|
-
result += chr + charAt$
|
|
1435
|
+
result += chr + charAt$6(string, ++index);
|
|
1436
1436
|
continue;
|
|
1437
1437
|
}
|
|
1438
1438
|
if (!brackets && chr === '.') {
|
|
@@ -1459,9 +1459,9 @@ var handleNCG = function (string) {
|
|
|
1459
1459
|
var groupname = '';
|
|
1460
1460
|
var chr;
|
|
1461
1461
|
for (; index <= length; index++) {
|
|
1462
|
-
chr = charAt$
|
|
1462
|
+
chr = charAt$6(string, index);
|
|
1463
1463
|
if (chr === '\\') {
|
|
1464
|
-
chr = chr + charAt$
|
|
1464
|
+
chr = chr + charAt$6(string, ++index);
|
|
1465
1465
|
} else if (chr === ']') {
|
|
1466
1466
|
brackets = false;
|
|
1467
1467
|
} else if (!brackets) switch (true) {
|
|
@@ -1574,14 +1574,14 @@ setSpecies('RegExp');
|
|
|
1574
1574
|
|
|
1575
1575
|
|
|
1576
1576
|
|
|
1577
|
-
var getInternalState = internalState.get;
|
|
1577
|
+
var getInternalState$1 = internalState.get;
|
|
1578
1578
|
|
|
1579
1579
|
|
|
1580
1580
|
|
|
1581
1581
|
var nativeReplace = shared('native-string-replace', String.prototype.replace);
|
|
1582
1582
|
var nativeExec = RegExp.prototype.exec;
|
|
1583
1583
|
var patchedExec = nativeExec;
|
|
1584
|
-
var charAt$
|
|
1584
|
+
var charAt$5 = functionUncurryThis(''.charAt);
|
|
1585
1585
|
var indexOf = functionUncurryThis(''.indexOf);
|
|
1586
1586
|
var replace$2 = functionUncurryThis(''.replace);
|
|
1587
1587
|
var stringSlice$6 = functionUncurryThis(''.slice);
|
|
@@ -1604,7 +1604,7 @@ var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || rege
|
|
|
1604
1604
|
if (PATCH) {
|
|
1605
1605
|
patchedExec = function exec(string) {
|
|
1606
1606
|
var re = this;
|
|
1607
|
-
var state = getInternalState(re);
|
|
1607
|
+
var state = getInternalState$1(re);
|
|
1608
1608
|
var str = toString_1(string);
|
|
1609
1609
|
var raw = state.raw;
|
|
1610
1610
|
var result, reCopy, lastIndex, match, i, object, group;
|
|
@@ -1631,7 +1631,7 @@ if (PATCH) {
|
|
|
1631
1631
|
|
|
1632
1632
|
strCopy = stringSlice$6(str, re.lastIndex);
|
|
1633
1633
|
// Support anchored sticky behavior.
|
|
1634
|
-
if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$
|
|
1634
|
+
if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$5(str, re.lastIndex - 1) !== '\n')) {
|
|
1635
1635
|
source = '(?: ' + source + ')';
|
|
1636
1636
|
strCopy = ' ' + strCopy;
|
|
1637
1637
|
charsAdded++;
|
|
@@ -1688,7 +1688,7 @@ _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
|
|
|
1688
1688
|
exec: regexpExec
|
|
1689
1689
|
});
|
|
1690
1690
|
|
|
1691
|
-
var PROPER_FUNCTION_NAME = functionName.PROPER;
|
|
1691
|
+
var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
|
|
1692
1692
|
|
|
1693
1693
|
|
|
1694
1694
|
|
|
@@ -1701,7 +1701,7 @@ var nativeToString = RegExpPrototype$1[TO_STRING];
|
|
|
1701
1701
|
|
|
1702
1702
|
var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
|
|
1703
1703
|
// FF44- RegExp#toString has a wrong name
|
|
1704
|
-
var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name != TO_STRING;
|
|
1704
|
+
var INCORRECT_NAME = PROPER_FUNCTION_NAME$1 && nativeToString.name != TO_STRING;
|
|
1705
1705
|
|
|
1706
1706
|
// `RegExp.prototype.toString` method
|
|
1707
1707
|
// https://tc39.es/ecma262/#sec-regexp.prototype.tostring
|
|
@@ -1795,7 +1795,7 @@ var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
|
|
|
1795
1795
|
if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
|
|
1796
1796
|
};
|
|
1797
1797
|
|
|
1798
|
-
var charAt$
|
|
1798
|
+
var charAt$4 = functionUncurryThis(''.charAt);
|
|
1799
1799
|
var charCodeAt$1 = functionUncurryThis(''.charCodeAt);
|
|
1800
1800
|
var stringSlice$5 = functionUncurryThis(''.slice);
|
|
1801
1801
|
|
|
@@ -1810,7 +1810,7 @@ var createMethod$3 = function (CONVERT_TO_STRING) {
|
|
|
1810
1810
|
return first < 0xD800 || first > 0xDBFF || position + 1 === size
|
|
1811
1811
|
|| (second = charCodeAt$1(S, position + 1)) < 0xDC00 || second > 0xDFFF
|
|
1812
1812
|
? CONVERT_TO_STRING
|
|
1813
|
-
? charAt$
|
|
1813
|
+
? charAt$4(S, position)
|
|
1814
1814
|
: first
|
|
1815
1815
|
: CONVERT_TO_STRING
|
|
1816
1816
|
? stringSlice$5(S, position, position + 2)
|
|
@@ -1827,12 +1827,12 @@ var stringMultibyte = {
|
|
|
1827
1827
|
charAt: createMethod$3(true)
|
|
1828
1828
|
};
|
|
1829
1829
|
|
|
1830
|
-
var charAt$
|
|
1830
|
+
var charAt$3 = stringMultibyte.charAt;
|
|
1831
1831
|
|
|
1832
1832
|
// `AdvanceStringIndex` abstract operation
|
|
1833
1833
|
// https://tc39.es/ecma262/#sec-advancestringindex
|
|
1834
1834
|
var advanceStringIndex = function (S, index, unicode) {
|
|
1835
|
-
return index + (unicode ? charAt$
|
|
1835
|
+
return index + (unicode ? charAt$3(S, index).length : 1);
|
|
1836
1836
|
};
|
|
1837
1837
|
|
|
1838
1838
|
var $TypeError$a = TypeError;
|
|
@@ -1933,7 +1933,7 @@ var functionApply = typeof Reflect == 'object' && Reflect.apply || (functionBind
|
|
|
1933
1933
|
});
|
|
1934
1934
|
|
|
1935
1935
|
var floor$1 = Math.floor;
|
|
1936
|
-
var charAt$
|
|
1936
|
+
var charAt$2 = functionUncurryThis(''.charAt);
|
|
1937
1937
|
var replace$1 = functionUncurryThis(''.replace);
|
|
1938
1938
|
var stringSlice$4 = functionUncurryThis(''.slice);
|
|
1939
1939
|
// eslint-disable-next-line redos/no-vulnerable -- safe
|
|
@@ -1952,7 +1952,7 @@ var getSubstitution = function (matched, str, position, captures, namedCaptures,
|
|
|
1952
1952
|
}
|
|
1953
1953
|
return replace$1(replacement, symbols, function (match, ch) {
|
|
1954
1954
|
var capture;
|
|
1955
|
-
switch (charAt$
|
|
1955
|
+
switch (charAt$2(ch, 0)) {
|
|
1956
1956
|
case '$': return '$';
|
|
1957
1957
|
case '&': return matched;
|
|
1958
1958
|
case '`': return stringSlice$4(str, 0, position);
|
|
@@ -1966,7 +1966,7 @@ var getSubstitution = function (matched, str, position, captures, namedCaptures,
|
|
|
1966
1966
|
if (n > m) {
|
|
1967
1967
|
var f = floor$1(n / 10);
|
|
1968
1968
|
if (f === 0) return match;
|
|
1969
|
-
if (f <= m) return captures[f - 1] === undefined ? charAt$
|
|
1969
|
+
if (f <= m) return captures[f - 1] === undefined ? charAt$2(ch, 1) : captures[f - 1] + charAt$2(ch, 1);
|
|
1970
1970
|
return match;
|
|
1971
1971
|
}
|
|
1972
1972
|
capture = captures[n - 1];
|
|
@@ -2201,7 +2201,7 @@ var arraySlice = functionUncurryThis([].slice);
|
|
|
2201
2201
|
var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('slice');
|
|
2202
2202
|
|
|
2203
2203
|
var SPECIES$2 = wellKnownSymbol('species');
|
|
2204
|
-
var $Array$
|
|
2204
|
+
var $Array$2 = Array;
|
|
2205
2205
|
var max$2 = Math.max;
|
|
2206
2206
|
|
|
2207
2207
|
// `Array.prototype.slice` method
|
|
@@ -2218,17 +2218,17 @@ _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 }, {
|
|
|
2218
2218
|
if (isArray(O)) {
|
|
2219
2219
|
Constructor = O.constructor;
|
|
2220
2220
|
// cross-realm fallback
|
|
2221
|
-
if (isConstructor(Constructor) && (Constructor === $Array$
|
|
2221
|
+
if (isConstructor(Constructor) && (Constructor === $Array$2 || isArray(Constructor.prototype))) {
|
|
2222
2222
|
Constructor = undefined;
|
|
2223
2223
|
} else if (isObject(Constructor)) {
|
|
2224
2224
|
Constructor = Constructor[SPECIES$2];
|
|
2225
2225
|
if (Constructor === null) Constructor = undefined;
|
|
2226
2226
|
}
|
|
2227
|
-
if (Constructor === $Array$
|
|
2227
|
+
if (Constructor === $Array$2 || Constructor === undefined) {
|
|
2228
2228
|
return arraySlice(O, k, fin);
|
|
2229
2229
|
}
|
|
2230
2230
|
}
|
|
2231
|
-
result = new (Constructor === undefined ? $Array$
|
|
2231
|
+
result = new (Constructor === undefined ? $Array$2 : Constructor)(max$2(fin - k, 0));
|
|
2232
2232
|
for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
|
|
2233
2233
|
result.length = n;
|
|
2234
2234
|
return result;
|
|
@@ -2409,20 +2409,20 @@ var stringTrim = {
|
|
|
2409
2409
|
var trim$1 = stringTrim.trim;
|
|
2410
2410
|
|
|
2411
2411
|
|
|
2412
|
-
var charAt = functionUncurryThis(''.charAt);
|
|
2412
|
+
var charAt$1 = functionUncurryThis(''.charAt);
|
|
2413
2413
|
var $parseFloat = global_1.parseFloat;
|
|
2414
2414
|
var Symbol$1 = global_1.Symbol;
|
|
2415
|
-
var ITERATOR$
|
|
2415
|
+
var ITERATOR$5 = Symbol$1 && Symbol$1.iterator;
|
|
2416
2416
|
var FORCED$2 = 1 / $parseFloat(whitespaces + '-0') !== -Infinity
|
|
2417
2417
|
// MS Edge 18- broken with boxed symbols
|
|
2418
|
-
|| (ITERATOR$
|
|
2418
|
+
|| (ITERATOR$5 && !fails(function () { $parseFloat(Object(ITERATOR$5)); }));
|
|
2419
2419
|
|
|
2420
2420
|
// `parseFloat` method
|
|
2421
2421
|
// https://tc39.es/ecma262/#sec-parsefloat-string
|
|
2422
2422
|
var numberParseFloat = FORCED$2 ? function parseFloat(string) {
|
|
2423
2423
|
var trimmedString = trim$1(toString_1(string));
|
|
2424
2424
|
var result = $parseFloat(trimmedString);
|
|
2425
|
-
return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;
|
|
2425
|
+
return result === 0 && charAt$1(trimmedString, 0) == '-' ? -0 : result;
|
|
2426
2426
|
} : $parseFloat;
|
|
2427
2427
|
|
|
2428
2428
|
// `parseFloat` method
|
|
@@ -2449,14 +2449,14 @@ var speciesConstructor = function (O, defaultConstructor) {
|
|
|
2449
2449
|
return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S);
|
|
2450
2450
|
};
|
|
2451
2451
|
|
|
2452
|
-
var $Array = Array;
|
|
2452
|
+
var $Array$1 = Array;
|
|
2453
2453
|
var max$1 = Math.max;
|
|
2454
2454
|
|
|
2455
2455
|
var arraySliceSimple = function (O, start, end) {
|
|
2456
2456
|
var length = lengthOfArrayLike(O);
|
|
2457
2457
|
var k = toAbsoluteIndex(start, length);
|
|
2458
2458
|
var fin = toAbsoluteIndex(end === undefined ? length : end, length);
|
|
2459
|
-
var result = $Array(max$1(fin - k, 0));
|
|
2459
|
+
var result = $Array$1(max$1(fin - k, 0));
|
|
2460
2460
|
for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
|
|
2461
2461
|
result.length = n;
|
|
2462
2462
|
return result;
|
|
@@ -3094,7 +3094,7 @@ var FORCED_PROMISE_CONSTRUCTOR$4 = promiseConstructorDetection.CONSTRUCTOR;
|
|
|
3094
3094
|
var NATIVE_PROMISE_REJECTION_EVENT = promiseConstructorDetection.REJECTION_EVENT;
|
|
3095
3095
|
var NATIVE_PROMISE_SUBCLASSING = promiseConstructorDetection.SUBCLASSING;
|
|
3096
3096
|
var getInternalPromiseState = internalState.getterFor(PROMISE);
|
|
3097
|
-
var setInternalState = internalState.set;
|
|
3097
|
+
var setInternalState$1 = internalState.set;
|
|
3098
3098
|
var NativePromisePrototype$1 = promiseNativeConstructor && promiseNativeConstructor.prototype;
|
|
3099
3099
|
var PromiseConstructor = promiseNativeConstructor;
|
|
3100
3100
|
var PromisePrototype = NativePromisePrototype$1;
|
|
@@ -3278,7 +3278,7 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
|
|
|
3278
3278
|
|
|
3279
3279
|
// eslint-disable-next-line no-unused-vars -- required for `.length`
|
|
3280
3280
|
Internal = function Promise(executor) {
|
|
3281
|
-
setInternalState(this, {
|
|
3281
|
+
setInternalState$1(this, {
|
|
3282
3282
|
type: PROMISE,
|
|
3283
3283
|
done: false,
|
|
3284
3284
|
notified: false,
|
|
@@ -3355,18 +3355,18 @@ setSpecies(PROMISE);
|
|
|
3355
3355
|
|
|
3356
3356
|
var iterators = {};
|
|
3357
3357
|
|
|
3358
|
-
var ITERATOR$
|
|
3358
|
+
var ITERATOR$4 = wellKnownSymbol('iterator');
|
|
3359
3359
|
var ArrayPrototype = Array.prototype;
|
|
3360
3360
|
|
|
3361
3361
|
// check on default Array iterator
|
|
3362
3362
|
var isArrayIteratorMethod = function (it) {
|
|
3363
|
-
return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR$
|
|
3363
|
+
return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR$4] === it);
|
|
3364
3364
|
};
|
|
3365
3365
|
|
|
3366
|
-
var ITERATOR$
|
|
3366
|
+
var ITERATOR$3 = wellKnownSymbol('iterator');
|
|
3367
3367
|
|
|
3368
3368
|
var getIteratorMethod = function (it) {
|
|
3369
|
-
if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR$
|
|
3369
|
+
if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR$3)
|
|
3370
3370
|
|| getMethod(it, '@@iterator')
|
|
3371
3371
|
|| iterators[classof(it)];
|
|
3372
3372
|
};
|
|
@@ -3457,7 +3457,7 @@ var iterate = function (iterable, unboundFunction, options) {
|
|
|
3457
3457
|
} return new Result(false);
|
|
3458
3458
|
};
|
|
3459
3459
|
|
|
3460
|
-
var ITERATOR = wellKnownSymbol('iterator');
|
|
3460
|
+
var ITERATOR$2 = wellKnownSymbol('iterator');
|
|
3461
3461
|
var SAFE_CLOSING = false;
|
|
3462
3462
|
|
|
3463
3463
|
try {
|
|
@@ -3470,7 +3470,7 @@ try {
|
|
|
3470
3470
|
SAFE_CLOSING = true;
|
|
3471
3471
|
}
|
|
3472
3472
|
};
|
|
3473
|
-
iteratorWithReturn[ITERATOR] = function () {
|
|
3473
|
+
iteratorWithReturn[ITERATOR$2] = function () {
|
|
3474
3474
|
return this;
|
|
3475
3475
|
};
|
|
3476
3476
|
// eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
|
|
@@ -3482,7 +3482,7 @@ var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
|
|
|
3482
3482
|
var ITERATION_SUPPORT = false;
|
|
3483
3483
|
try {
|
|
3484
3484
|
var object = {};
|
|
3485
|
-
object[ITERATOR] = function () {
|
|
3485
|
+
object[ITERATOR$2] = function () {
|
|
3486
3486
|
return {
|
|
3487
3487
|
next: function () {
|
|
3488
3488
|
return { done: ITERATION_SUPPORT = true };
|
|
@@ -3977,6 +3977,236 @@ _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
|
|
|
3977
3977
|
}
|
|
3978
3978
|
});
|
|
3979
3979
|
|
|
3980
|
+
// call something on iterator step with safe closing on error
|
|
3981
|
+
var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
|
|
3982
|
+
try {
|
|
3983
|
+
return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
|
|
3984
|
+
} catch (error) {
|
|
3985
|
+
iteratorClose(iterator, 'throw', error);
|
|
3986
|
+
}
|
|
3987
|
+
};
|
|
3988
|
+
|
|
3989
|
+
var $Array = Array;
|
|
3990
|
+
|
|
3991
|
+
// `Array.from` method implementation
|
|
3992
|
+
// https://tc39.es/ecma262/#sec-array.from
|
|
3993
|
+
var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
|
|
3994
|
+
var O = toObject(arrayLike);
|
|
3995
|
+
var IS_CONSTRUCTOR = isConstructor(this);
|
|
3996
|
+
var argumentsLength = arguments.length;
|
|
3997
|
+
var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
|
|
3998
|
+
var mapping = mapfn !== undefined;
|
|
3999
|
+
if (mapping) mapfn = functionBindContext(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
|
|
4000
|
+
var iteratorMethod = getIteratorMethod(O);
|
|
4001
|
+
var index = 0;
|
|
4002
|
+
var length, result, step, iterator, next, value;
|
|
4003
|
+
// if the target is not iterable or it's an array with the default iterator - use a simple case
|
|
4004
|
+
if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
|
|
4005
|
+
iterator = getIterator(O, iteratorMethod);
|
|
4006
|
+
next = iterator.next;
|
|
4007
|
+
result = IS_CONSTRUCTOR ? new this() : [];
|
|
4008
|
+
for (;!(step = functionCall(next, iterator)).done; index++) {
|
|
4009
|
+
value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
|
|
4010
|
+
createProperty(result, index, value);
|
|
4011
|
+
}
|
|
4012
|
+
} else {
|
|
4013
|
+
length = lengthOfArrayLike(O);
|
|
4014
|
+
result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
|
|
4015
|
+
for (;length > index; index++) {
|
|
4016
|
+
value = mapping ? mapfn(O[index], index) : O[index];
|
|
4017
|
+
createProperty(result, index, value);
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
result.length = index;
|
|
4021
|
+
return result;
|
|
4022
|
+
};
|
|
4023
|
+
|
|
4024
|
+
var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
|
|
4025
|
+
// eslint-disable-next-line es/no-array-from -- required for testing
|
|
4026
|
+
Array.from(iterable);
|
|
4027
|
+
});
|
|
4028
|
+
|
|
4029
|
+
// `Array.from` method
|
|
4030
|
+
// https://tc39.es/ecma262/#sec-array.from
|
|
4031
|
+
_export({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
|
|
4032
|
+
from: arrayFrom
|
|
4033
|
+
});
|
|
4034
|
+
|
|
4035
|
+
var ITERATOR$1 = wellKnownSymbol('iterator');
|
|
4036
|
+
var BUGGY_SAFARI_ITERATORS$1 = false;
|
|
4037
|
+
|
|
4038
|
+
// `%IteratorPrototype%` object
|
|
4039
|
+
// https://tc39.es/ecma262/#sec-%iteratorprototype%-object
|
|
4040
|
+
var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
|
|
4041
|
+
|
|
4042
|
+
/* eslint-disable es/no-array-prototype-keys -- safe */
|
|
4043
|
+
if ([].keys) {
|
|
4044
|
+
arrayIterator = [].keys();
|
|
4045
|
+
// Safari 8 has buggy iterators w/o `next`
|
|
4046
|
+
if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true;
|
|
4047
|
+
else {
|
|
4048
|
+
PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
|
|
4049
|
+
if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails(function () {
|
|
4054
|
+
var test = {};
|
|
4055
|
+
// FF44- legacy iterators case
|
|
4056
|
+
return IteratorPrototype$2[ITERATOR$1].call(test) !== test;
|
|
4057
|
+
});
|
|
4058
|
+
|
|
4059
|
+
if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
|
|
4060
|
+
|
|
4061
|
+
// `%IteratorPrototype%[@@iterator]()` method
|
|
4062
|
+
// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
|
|
4063
|
+
if (!isCallable(IteratorPrototype$2[ITERATOR$1])) {
|
|
4064
|
+
defineBuiltIn(IteratorPrototype$2, ITERATOR$1, function () {
|
|
4065
|
+
return this;
|
|
4066
|
+
});
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
var iteratorsCore = {
|
|
4070
|
+
IteratorPrototype: IteratorPrototype$2,
|
|
4071
|
+
BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1
|
|
4072
|
+
};
|
|
4073
|
+
|
|
4074
|
+
var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
|
|
4075
|
+
|
|
4076
|
+
|
|
4077
|
+
|
|
4078
|
+
|
|
4079
|
+
|
|
4080
|
+
var returnThis$1 = function () { return this; };
|
|
4081
|
+
|
|
4082
|
+
var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
|
|
4083
|
+
var TO_STRING_TAG = NAME + ' Iterator';
|
|
4084
|
+
IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
|
|
4085
|
+
setToStringTag(IteratorConstructor, TO_STRING_TAG, false);
|
|
4086
|
+
iterators[TO_STRING_TAG] = returnThis$1;
|
|
4087
|
+
return IteratorConstructor;
|
|
4088
|
+
};
|
|
4089
|
+
|
|
4090
|
+
var PROPER_FUNCTION_NAME = functionName.PROPER;
|
|
4091
|
+
var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
|
|
4092
|
+
var IteratorPrototype = iteratorsCore.IteratorPrototype;
|
|
4093
|
+
var BUGGY_SAFARI_ITERATORS = iteratorsCore.BUGGY_SAFARI_ITERATORS;
|
|
4094
|
+
var ITERATOR = wellKnownSymbol('iterator');
|
|
4095
|
+
var KEYS = 'keys';
|
|
4096
|
+
var VALUES = 'values';
|
|
4097
|
+
var ENTRIES = 'entries';
|
|
4098
|
+
|
|
4099
|
+
var returnThis = function () { return this; };
|
|
4100
|
+
|
|
4101
|
+
var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
|
|
4102
|
+
iteratorCreateConstructor(IteratorConstructor, NAME, next);
|
|
4103
|
+
|
|
4104
|
+
var getIterationMethod = function (KIND) {
|
|
4105
|
+
if (KIND === DEFAULT && defaultIterator) return defaultIterator;
|
|
4106
|
+
if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
|
|
4107
|
+
switch (KIND) {
|
|
4108
|
+
case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
|
|
4109
|
+
case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
|
|
4110
|
+
case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
|
|
4111
|
+
} return function () { return new IteratorConstructor(this); };
|
|
4112
|
+
};
|
|
4113
|
+
|
|
4114
|
+
var TO_STRING_TAG = NAME + ' Iterator';
|
|
4115
|
+
var INCORRECT_VALUES_NAME = false;
|
|
4116
|
+
var IterablePrototype = Iterable.prototype;
|
|
4117
|
+
var nativeIterator = IterablePrototype[ITERATOR]
|
|
4118
|
+
|| IterablePrototype['@@iterator']
|
|
4119
|
+
|| DEFAULT && IterablePrototype[DEFAULT];
|
|
4120
|
+
var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
|
|
4121
|
+
var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
|
|
4122
|
+
var CurrentIteratorPrototype, methods, KEY;
|
|
4123
|
+
|
|
4124
|
+
// fix native
|
|
4125
|
+
if (anyNativeIterator) {
|
|
4126
|
+
CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
|
|
4127
|
+
if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
|
|
4128
|
+
if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
|
|
4129
|
+
if (objectSetPrototypeOf) {
|
|
4130
|
+
objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
|
|
4131
|
+
} else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
|
|
4132
|
+
defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
// Set @@toStringTag to native iterators
|
|
4136
|
+
setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true);
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
|
|
4140
|
+
// fix Array.prototype.{ values, @@iterator }.name in V8 / FF
|
|
4141
|
+
if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
|
|
4142
|
+
if (CONFIGURABLE_FUNCTION_NAME) {
|
|
4143
|
+
createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
|
|
4144
|
+
} else {
|
|
4145
|
+
INCORRECT_VALUES_NAME = true;
|
|
4146
|
+
defaultIterator = function values() { return functionCall(nativeIterator, this); };
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4150
|
+
// export additional methods
|
|
4151
|
+
if (DEFAULT) {
|
|
4152
|
+
methods = {
|
|
4153
|
+
values: getIterationMethod(VALUES),
|
|
4154
|
+
keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
|
|
4155
|
+
entries: getIterationMethod(ENTRIES)
|
|
4156
|
+
};
|
|
4157
|
+
if (FORCED) for (KEY in methods) {
|
|
4158
|
+
if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
|
|
4159
|
+
defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
|
|
4160
|
+
}
|
|
4161
|
+
} else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
// define iterator
|
|
4165
|
+
if (IterablePrototype[ITERATOR] !== defaultIterator) {
|
|
4166
|
+
defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
|
|
4167
|
+
}
|
|
4168
|
+
iterators[NAME] = defaultIterator;
|
|
4169
|
+
|
|
4170
|
+
return methods;
|
|
4171
|
+
};
|
|
4172
|
+
|
|
4173
|
+
// `CreateIterResultObject` abstract operation
|
|
4174
|
+
// https://tc39.es/ecma262/#sec-createiterresultobject
|
|
4175
|
+
var createIterResultObject = function (value, done) {
|
|
4176
|
+
return { value: value, done: done };
|
|
4177
|
+
};
|
|
4178
|
+
|
|
4179
|
+
var charAt = stringMultibyte.charAt;
|
|
4180
|
+
|
|
4181
|
+
|
|
4182
|
+
|
|
4183
|
+
|
|
4184
|
+
|
|
4185
|
+
var STRING_ITERATOR = 'String Iterator';
|
|
4186
|
+
var setInternalState = internalState.set;
|
|
4187
|
+
var getInternalState = internalState.getterFor(STRING_ITERATOR);
|
|
4188
|
+
|
|
4189
|
+
// `String.prototype[@@iterator]` method
|
|
4190
|
+
// https://tc39.es/ecma262/#sec-string.prototype-@@iterator
|
|
4191
|
+
iteratorDefine(String, 'String', function (iterated) {
|
|
4192
|
+
setInternalState(this, {
|
|
4193
|
+
type: STRING_ITERATOR,
|
|
4194
|
+
string: toString_1(iterated),
|
|
4195
|
+
index: 0
|
|
4196
|
+
});
|
|
4197
|
+
// `%StringIteratorPrototype%.next` method
|
|
4198
|
+
// https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
|
|
4199
|
+
}, function next() {
|
|
4200
|
+
var state = getInternalState(this);
|
|
4201
|
+
var string = state.string;
|
|
4202
|
+
var index = state.index;
|
|
4203
|
+
var point;
|
|
4204
|
+
if (index >= string.length) return createIterResultObject(undefined, true);
|
|
4205
|
+
point = charAt(string, index);
|
|
4206
|
+
state.index += point.length;
|
|
4207
|
+
return createIterResultObject(point, false);
|
|
4208
|
+
});
|
|
4209
|
+
|
|
3980
4210
|
/*! *****************************************************************************
|
|
3981
4211
|
Copyright (c) Microsoft Corporation.
|
|
3982
4212
|
|
|
@@ -4132,34 +4362,32 @@ function getQueryParam(param) {
|
|
|
4132
4362
|
return '';
|
|
4133
4363
|
}
|
|
4134
4364
|
/**
|
|
4135
|
-
*
|
|
4365
|
+
* Returns the value of the specified query parameter in the input URL.
|
|
4136
4366
|
*
|
|
4367
|
+
* @example
|
|
4137
4368
|
* ```
|
|
4138
|
-
* getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3'); // 3
|
|
4139
|
-
* getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4'); // 4
|
|
4369
|
+
* getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3'); // Returns '3'
|
|
4370
|
+
* getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4'); // Returns '4'
|
|
4140
4371
|
* ```
|
|
4141
4372
|
*
|
|
4142
|
-
* @param {string} url URL string.
|
|
4143
|
-
* @param {string} param
|
|
4144
|
-
* @returns {string} value
|
|
4373
|
+
* @param {string} url The URL string.
|
|
4374
|
+
* @param {string} param The query parameter to retrieve the value for.
|
|
4375
|
+
* @returns {string|string[]} The value of the specified query parameter, or an empty string if the parameter is not found.
|
|
4145
4376
|
* @category URL
|
|
4146
4377
|
*/
|
|
4147
4378
|
function getUrlParam(url, param) {
|
|
4148
4379
|
var result = {};
|
|
4149
|
-
|
|
4150
|
-
url.replace(/\??(\w+)=([^&]*)&?/g, function (a, k, v) {
|
|
4380
|
+
url.replace(/\??(\w+)=([^&]*)&?/g, function (_, k, v) {
|
|
4151
4381
|
if (result[k] !== undefined) {
|
|
4152
4382
|
var t = result[k];
|
|
4383
|
+
// Cast `t` to `string[]` to ensure that `concat` receives an array
|
|
4153
4384
|
result[k] = [].concat(t, v);
|
|
4154
4385
|
} else {
|
|
4155
4386
|
result[k] = v;
|
|
4156
4387
|
}
|
|
4388
|
+
// Return an empty string to satisfy the signature of the replace method
|
|
4389
|
+
return '';
|
|
4157
4390
|
});
|
|
4158
|
-
// if (param === undefined) {
|
|
4159
|
-
// return result;
|
|
4160
|
-
// } else {
|
|
4161
|
-
// return result[param] || '';
|
|
4162
|
-
// }
|
|
4163
4391
|
return result[param] || '';
|
|
4164
4392
|
}
|
|
4165
4393
|
/**
|
|
@@ -4441,8 +4669,8 @@ function generateRndNum(n) {
|
|
|
4441
4669
|
return ret;
|
|
4442
4670
|
}
|
|
4443
4671
|
/**
|
|
4444
|
-
*
|
|
4445
|
-
*
|
|
4672
|
+
* 根据时间生成唯一标志的数字 mGenerateUniqueNum() => 1538324722364123
|
|
4673
|
+
*
|
|
4446
4674
|
* @param {number} n 随机数的长度
|
|
4447
4675
|
* @category Util
|
|
4448
4676
|
*/
|
|
@@ -4456,8 +4684,8 @@ function generateUniqueNum(n) {
|
|
|
4456
4684
|
return now + rnd;
|
|
4457
4685
|
}
|
|
4458
4686
|
/**
|
|
4459
|
-
*
|
|
4460
|
-
*
|
|
4687
|
+
* 浮点数转为百分比 0.2 => 20%
|
|
4688
|
+
*
|
|
4461
4689
|
* @param {number} num 浮点数
|
|
4462
4690
|
* @param {number} fixSize 保留几位浮点数
|
|
4463
4691
|
* @category Util
|
|
@@ -4475,8 +4703,8 @@ function floatToPercent(num, fixSize) {
|
|
|
4475
4703
|
return "".concat(ret, "%");
|
|
4476
4704
|
}
|
|
4477
4705
|
/**
|
|
4478
|
-
*
|
|
4479
|
-
*
|
|
4706
|
+
* 浮点数保留指定位
|
|
4707
|
+
*
|
|
4480
4708
|
* @category Util
|
|
4481
4709
|
*/
|
|
4482
4710
|
function floatFixed(num, size) {
|
|
@@ -4486,9 +4714,9 @@ function floatFixed(num, size) {
|
|
|
4486
4714
|
return parseFloat(num).toFixed(size);
|
|
4487
4715
|
}
|
|
4488
4716
|
/**
|
|
4489
|
-
*
|
|
4490
|
-
*
|
|
4491
|
-
* @category
|
|
4717
|
+
* 阻止冒泡
|
|
4718
|
+
*
|
|
4719
|
+
* @category Event
|
|
4492
4720
|
*/
|
|
4493
4721
|
function cancelBubble(e) {
|
|
4494
4722
|
var ev = e || window.event;
|
|
@@ -4599,8 +4827,6 @@ function throttle(func, wait, options) {
|
|
|
4599
4827
|
options = {};
|
|
4600
4828
|
}
|
|
4601
4829
|
options = Object.assign({}, options);
|
|
4602
|
-
// timeout: setTimeout Handle
|
|
4603
|
-
// previous: 上次时间戳
|
|
4604
4830
|
var context = null;
|
|
4605
4831
|
var args = null;
|
|
4606
4832
|
var timeout = null;
|
|
@@ -4610,7 +4836,7 @@ function throttle(func, wait, options) {
|
|
|
4610
4836
|
var later = function later() {
|
|
4611
4837
|
previous = options.leading === false ? 0 : mNow();
|
|
4612
4838
|
timeout = null;
|
|
4613
|
-
result = func.apply(
|
|
4839
|
+
result = func.apply(this, args);
|
|
4614
4840
|
if (!timeout) {
|
|
4615
4841
|
context = args = null;
|
|
4616
4842
|
}
|
|
@@ -4638,7 +4864,7 @@ function throttle(func, wait, options) {
|
|
|
4638
4864
|
context = args = null;
|
|
4639
4865
|
}
|
|
4640
4866
|
} else if (!timeout && options.trailing !== false) {
|
|
4641
|
-
timeout = setTimeout(later, remaining);
|
|
4867
|
+
timeout = setTimeout(later.bind(context), remaining);
|
|
4642
4868
|
}
|
|
4643
4869
|
return result;
|
|
4644
4870
|
};
|
|
@@ -4661,7 +4887,7 @@ function debounce(func, wait, immediate) {
|
|
|
4661
4887
|
var timeout = null;
|
|
4662
4888
|
var timestamp = null;
|
|
4663
4889
|
var args = null;
|
|
4664
|
-
var result =
|
|
4890
|
+
var result = null;
|
|
4665
4891
|
var later = function later() {
|
|
4666
4892
|
var last = mNow() - timestamp;
|
|
4667
4893
|
if (last < wait && last >= 0) {
|
|
@@ -4780,37 +5006,26 @@ function getFriendlyInterval(start, end, options) {
|
|
|
4780
5006
|
*/
|
|
4781
5007
|
function isNumber(num, options) {
|
|
4782
5008
|
if (options === void 0) {
|
|
4783
|
-
options = {
|
|
4784
|
-
isNaNAsNumber: false,
|
|
4785
|
-
isUnFiniteAsNumber: false
|
|
4786
|
-
};
|
|
5009
|
+
options = {};
|
|
4787
5010
|
}
|
|
4788
|
-
var _a =
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
isNaNAsNumber = _a.isNaNAsNumber,
|
|
4793
|
-
isUnFiniteAsNumber = _a.isUnFiniteAsNumber;
|
|
4794
|
-
var ret = true;
|
|
4795
|
-
// 数字类型
|
|
5011
|
+
var _a = options.isNaNAsNumber,
|
|
5012
|
+
isNaNAsNumber = _a === void 0 ? false : _a,
|
|
5013
|
+
_b = options.isFiniteAsNumber,
|
|
5014
|
+
isFiniteAsNumber = _b === void 0 ? false : _b;
|
|
4796
5015
|
if (typeof num !== 'number') {
|
|
4797
|
-
|
|
5016
|
+
return false;
|
|
4798
5017
|
}
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
// console.log('1333');
|
|
4802
|
-
ret = false;
|
|
5018
|
+
if (!isFiniteAsNumber && !isFinite(num)) {
|
|
5019
|
+
return false;
|
|
4803
5020
|
}
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
// console.log('2333');
|
|
4807
|
-
ret = false;
|
|
5021
|
+
if (!isNaNAsNumber && isNaN(num)) {
|
|
5022
|
+
return false;
|
|
4808
5023
|
}
|
|
4809
|
-
return
|
|
5024
|
+
return true;
|
|
4810
5025
|
}
|
|
4811
5026
|
/**
|
|
4812
|
-
*
|
|
4813
|
-
*
|
|
5027
|
+
* 执行有效函数
|
|
5028
|
+
*
|
|
4814
5029
|
* @param {function} fn 等待被执行的未知是否有效的函数
|
|
4815
5030
|
* @category Util
|
|
4816
5031
|
*/
|
|
@@ -4848,7 +5063,7 @@ function doFn(fn) {
|
|
|
4848
5063
|
* ```
|
|
4849
5064
|
*
|
|
4850
5065
|
* @param {string} key 键
|
|
4851
|
-
* @returns {
|
|
5066
|
+
* @returns {void} 返回值
|
|
4852
5067
|
* @category Cache Data
|
|
4853
5068
|
*/
|
|
4854
5069
|
function setSessionStorage(key, value) {
|
|
@@ -4918,7 +5133,7 @@ function getSessionStorage(key) {
|
|
|
4918
5133
|
* ```
|
|
4919
5134
|
*
|
|
4920
5135
|
* @param {string} key 键
|
|
4921
|
-
* @returns {
|
|
5136
|
+
* @returns {void} 返回值
|
|
4922
5137
|
* @category Cache Data
|
|
4923
5138
|
*/
|
|
4924
5139
|
function setLocalStorage(key, value) {
|
|
@@ -5197,8 +5412,8 @@ function loadScript(url, options) {
|
|
|
5197
5412
|
});
|
|
5198
5413
|
}
|
|
5199
5414
|
/**
|
|
5200
|
-
*
|
|
5201
|
-
*
|
|
5415
|
+
* 获取时间戳
|
|
5416
|
+
*
|
|
5202
5417
|
* @category Util
|
|
5203
5418
|
*/
|
|
5204
5419
|
function mNow() {
|
|
@@ -5224,11 +5439,11 @@ function mNow() {
|
|
|
5224
5439
|
*/
|
|
5225
5440
|
function setCookie(name, value, days, domain) {
|
|
5226
5441
|
var domainParts, expires;
|
|
5227
|
-
|
|
5442
|
+
// let date: any;
|
|
5228
5443
|
if (days) {
|
|
5229
|
-
date = new Date();
|
|
5444
|
+
var date = new Date();
|
|
5230
5445
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
5231
|
-
expires = '; expires=' + date.
|
|
5446
|
+
expires = '; expires=' + date.toUTCString();
|
|
5232
5447
|
} else {
|
|
5233
5448
|
expires = '';
|
|
5234
5449
|
}
|
|
@@ -5873,14 +6088,50 @@ function getBrowserInfo() {
|
|
|
5873
6088
|
}
|
|
5874
6089
|
}
|
|
5875
6090
|
/**
|
|
5876
|
-
*
|
|
5877
|
-
*
|
|
6091
|
+
* 去除 HTML 标签
|
|
6092
|
+
*
|
|
5878
6093
|
* @param {string} str 带html标签的字符串
|
|
5879
6094
|
* @returns {string} 字符串
|
|
5880
6095
|
* @category Util
|
|
5881
6096
|
*/
|
|
5882
|
-
function clearHtml(str) {
|
|
5883
|
-
|
|
6097
|
+
function clearHtml(str, options) {
|
|
6098
|
+
if (options === void 0) {
|
|
6099
|
+
options = {};
|
|
6100
|
+
}
|
|
6101
|
+
var _a = options.removeNewLine,
|
|
6102
|
+
removeNewLine = _a === void 0 ? false : _a;
|
|
6103
|
+
var ret = '';
|
|
6104
|
+
if (str) {
|
|
6105
|
+
ret = str.replace(/<\/?.+?>/g, '');
|
|
6106
|
+
if (removeNewLine) {
|
|
6107
|
+
ret = ret.replace(/[\r\n]/g, '');
|
|
6108
|
+
}
|
|
6109
|
+
}
|
|
6110
|
+
return ret;
|
|
6111
|
+
// return str.replace(/<\/?.+?>/g, '').replace(/[\r\n]/g, '');
|
|
6112
|
+
}
|
|
6113
|
+
/**
|
|
6114
|
+
* Sanitizes user input to prevent XSS attacks
|
|
6115
|
+
*
|
|
6116
|
+
* @param input - The input string to sanitize
|
|
6117
|
+
* @returns The sanitized input string
|
|
6118
|
+
*/
|
|
6119
|
+
function sanitizeInput(input) {
|
|
6120
|
+
var regex = /[&<>"'/]/g;
|
|
6121
|
+
var replacements = {
|
|
6122
|
+
'&': '&',
|
|
6123
|
+
'<': '<',
|
|
6124
|
+
'>': '>',
|
|
6125
|
+
'"': '"',
|
|
6126
|
+
'\'': ''',
|
|
6127
|
+
'/': '/'
|
|
6128
|
+
};
|
|
6129
|
+
if (typeof input !== 'string') {
|
|
6130
|
+
console.error('Input must be a string');
|
|
6131
|
+
}
|
|
6132
|
+
return input.replace(regex, function (match) {
|
|
6133
|
+
return replacements[match];
|
|
6134
|
+
});
|
|
5884
6135
|
}
|
|
5885
6136
|
/**
|
|
5886
6137
|
* 截取字符串,中文算 2 个字节
|
|
@@ -6283,15 +6534,12 @@ function isNonEmptyArray(arr) {
|
|
|
6283
6534
|
function isValidData(data, attributes, validValue) {
|
|
6284
6535
|
var ret = false;
|
|
6285
6536
|
var foundRet = attributes.reduce(function (foundValue, curr) {
|
|
6286
|
-
if (foundValue
|
|
6287
|
-
|
|
6537
|
+
if (foundValue && Object.prototype.hasOwnProperty.call(foundValue, curr)) {
|
|
6538
|
+
return foundValue[curr];
|
|
6288
6539
|
} else {
|
|
6289
6540
|
return Object.create(null);
|
|
6290
6541
|
}
|
|
6291
|
-
// console.log('foundValue', foundValue);
|
|
6292
|
-
return foundValue;
|
|
6293
6542
|
}, data);
|
|
6294
|
-
// console.log('foundRet', foundRet);
|
|
6295
6543
|
if (foundRet === validValue) {
|
|
6296
6544
|
ret = true;
|
|
6297
6545
|
}
|
|
@@ -6608,6 +6856,130 @@ function getUrlFileType(url) {
|
|
|
6608
6856
|
// }
|
|
6609
6857
|
return ret;
|
|
6610
6858
|
}
|
|
6859
|
+
/**
|
|
6860
|
+
* Sets the width and height of all images on the page based on their `src` attribute.
|
|
6861
|
+
* The `src` attribute should contain `width` and/or `height` values in the format "width=100" or "height=100".
|
|
6862
|
+
* If jQuery is available, this function uses jQuery to select the images. Otherwise, it uses pure JavaScript.
|
|
6863
|
+
*
|
|
6864
|
+
* @example
|
|
6865
|
+
* ```
|
|
6866
|
+
* // Example images with `src` attributes containing `width` and/or `height` values
|
|
6867
|
+
* const img1 = document.createElement('img');
|
|
6868
|
+
* img1.setAttribute('src', 'https://example.com/example.png?width=2233&height=111');
|
|
6869
|
+
* document.body.appendChild(img1);
|
|
6870
|
+
*
|
|
6871
|
+
* const img2 = document.createElement('img');
|
|
6872
|
+
* img2.setAttribute('src', 'https://example.com/example.png?width=100%&height=auto');
|
|
6873
|
+
* document.body.appendChild(img2);
|
|
6874
|
+
* ```
|
|
6875
|
+
*
|
|
6876
|
+
* @returns {boolean} - Returns `true` if images were found and their dimensions were set, otherwise `false`.
|
|
6877
|
+
*/
|
|
6878
|
+
function setImgWidHeiBySrc() {
|
|
6879
|
+
// Use jQuery if available, otherwise fall back to pure JavaScript
|
|
6880
|
+
var $ = window.jQuery || window.$;
|
|
6881
|
+
if ($) {
|
|
6882
|
+
// Use jQuery to select all images on the page
|
|
6883
|
+
var images = $('img');
|
|
6884
|
+
if (!(images && images.length)) return false;
|
|
6885
|
+
images.each(function () {
|
|
6886
|
+
var $this = $(this);
|
|
6887
|
+
if (!$this) return;
|
|
6888
|
+
// Get the `src` attribute of the image
|
|
6889
|
+
var src = $this.attr('src');
|
|
6890
|
+
var canMatch = src && typeof src === 'string' && src.length;
|
|
6891
|
+
if (!canMatch) return;
|
|
6892
|
+
// Use regular expressions to extract the `width` and `height` values from the `src` attribute
|
|
6893
|
+
var width = src.match(/width=([0-9]+[a-z%]*)/);
|
|
6894
|
+
var height = src.match(/height=([0-9]+[a-z%]*)/);
|
|
6895
|
+
// Set the width and height of the image using jQuery's `width()` and `height()` methods
|
|
6896
|
+
if (width && isNonEmptyArray(width) && width[1]) $this.width(width[1]);
|
|
6897
|
+
if (height && isNonEmptyArray(height) && height[1]) $this.height(height[1]);
|
|
6898
|
+
});
|
|
6899
|
+
return true;
|
|
6900
|
+
} else {
|
|
6901
|
+
// Use pure JavaScript to select all images on the page
|
|
6902
|
+
var images = document.getElementsByTagName('img');
|
|
6903
|
+
if (images.length > 0) {
|
|
6904
|
+
// Loop through each image and set its width and height based on the `src` attribute
|
|
6905
|
+
Array.from(images).forEach(function (img) {
|
|
6906
|
+
var $this = img;
|
|
6907
|
+
if (!$this) return;
|
|
6908
|
+
// Get the `src` attribute of the image
|
|
6909
|
+
var src = $this.getAttribute('src');
|
|
6910
|
+
var canMatch = src && typeof src === 'string' && src.length;
|
|
6911
|
+
if (!canMatch) return;
|
|
6912
|
+
// Use regular expressions to extract the `width` and `height` values from the `src` attribute
|
|
6913
|
+
var width = src.match(/width=([0-9]+[a-z%]*)/);
|
|
6914
|
+
var height = src.match(/height=([0-9]+[a-z%]*)/);
|
|
6915
|
+
// Set the width and height of the image using the `style.width` and `style.height` properties
|
|
6916
|
+
if (width && isNonEmptyArray(width) && width[1]) $this.style.width = width[1];
|
|
6917
|
+
if (height && isNonEmptyArray(height) && height[1]) $this.style.height = height[1];
|
|
6918
|
+
});
|
|
6919
|
+
return true;
|
|
6920
|
+
}
|
|
6921
|
+
}
|
|
6922
|
+
return false;
|
|
6923
|
+
}
|
|
6924
|
+
/**
|
|
6925
|
+
* Generate the inline style string from the given parameters, First parameter is the ClassNames, Second parameter is the style array.
|
|
6926
|
+
*
|
|
6927
|
+
* @example
|
|
6928
|
+
* ```js
|
|
6929
|
+
* console.log(genStyleString('a', [ 'color:red' ])); // '.a{color:red;}'
|
|
6930
|
+
* console.log(genStyleString('b', [ 'color:red', 'font-size:12px' ])); // '.b{color:red;font-size:12px;}'
|
|
6931
|
+
* ```
|
|
6932
|
+
*
|
|
6933
|
+
* @param {string} className
|
|
6934
|
+
* @param {Array} styleArray
|
|
6935
|
+
* @returns {string} Return the inline style string.
|
|
6936
|
+
* @category DOM
|
|
6937
|
+
*/
|
|
6938
|
+
function genStyleString(className, styleArray) {
|
|
6939
|
+
var style = '';
|
|
6940
|
+
if (styleArray && styleArray.length > 0) {
|
|
6941
|
+
// It's wrong. Last item will not include `;`.
|
|
6942
|
+
// style = styleArray.join(';');
|
|
6943
|
+
style = styleArray.join(';') + ';';
|
|
6944
|
+
}
|
|
6945
|
+
return ".".concat(className, "{").concat(style, "}");
|
|
6946
|
+
}
|
|
6947
|
+
/**
|
|
6948
|
+
* Load the image from the given url.
|
|
6949
|
+
* The target image will be loaded in the background, and the Promise status will change after the image is loaded.
|
|
6950
|
+
* If the image fails to load, the Promise status will change to `reject`.
|
|
6951
|
+
* If the image is loaded successfully, the Promise status will change to `resolve`.
|
|
6952
|
+
* If the image is loaded successfully, the Promise will return the image object.
|
|
6953
|
+
* If the image fails to load, the Promise will return the error object.
|
|
6954
|
+
* The method will help Web to preload the image. And the image will be cached by the browser.
|
|
6955
|
+
* We can use it to implement the lazy loading of images.
|
|
6956
|
+
* The method will not add the image to the DOM.
|
|
6957
|
+
*
|
|
6958
|
+
* @example
|
|
6959
|
+
* ```js
|
|
6960
|
+
* loadImage('https://example.com/example.png').then((img) => {
|
|
6961
|
+
* console.log(img);
|
|
6962
|
+
* }).catch((err) => {
|
|
6963
|
+
* console.log(err);
|
|
6964
|
+
* });
|
|
6965
|
+
* ```
|
|
6966
|
+
*
|
|
6967
|
+
* @param {string} url - The image url.
|
|
6968
|
+
* @returns {Promise} Return the Promise object.
|
|
6969
|
+
* @category Load Resource
|
|
6970
|
+
*/
|
|
6971
|
+
function loadImage(url) {
|
|
6972
|
+
return new Promise(function (resolve, reject) {
|
|
6973
|
+
var img = new Image();
|
|
6974
|
+
img.onload = function () {
|
|
6975
|
+
resolve(img);
|
|
6976
|
+
};
|
|
6977
|
+
img.onerror = function (err) {
|
|
6978
|
+
reject(err);
|
|
6979
|
+
};
|
|
6980
|
+
img.src = url;
|
|
6981
|
+
});
|
|
6982
|
+
}
|
|
6611
6983
|
|
|
6612
6984
|
exports.addClass = addClass;
|
|
6613
6985
|
exports.addEvent = addEvent;
|
|
@@ -6630,6 +7002,7 @@ exports.floatToPercent = floatToPercent;
|
|
|
6630
7002
|
exports.formatDate = formatDate;
|
|
6631
7003
|
exports.genCustomConsole = genCustomConsole;
|
|
6632
7004
|
exports.genHashCode = genHashCode;
|
|
7005
|
+
exports.genStyleString = genStyleString;
|
|
6633
7006
|
exports.generateRndNum = generateRndNum;
|
|
6634
7007
|
exports.generateUniqueNum = generateUniqueNum;
|
|
6635
7008
|
exports.getBrowserInfo = getBrowserInfo;
|
|
@@ -6659,13 +7032,16 @@ exports.isValidEmail = isValidEmail;
|
|
|
6659
7032
|
exports.isValidPhoneNumber = isValidPhoneNumber;
|
|
6660
7033
|
exports.isValidUrl = isValidUrl;
|
|
6661
7034
|
exports.loadCSS = loadCSS;
|
|
7035
|
+
exports.loadImage = loadImage;
|
|
6662
7036
|
exports.loadScript = loadScript;
|
|
6663
7037
|
exports.mNow = mNow;
|
|
6664
7038
|
exports.mTrim = mTrim;
|
|
6665
7039
|
exports.newLine = newLine;
|
|
6666
7040
|
exports.removeClass = removeClass;
|
|
6667
7041
|
exports.removeEvent = removeEvent;
|
|
7042
|
+
exports.sanitizeInput = sanitizeInput;
|
|
6668
7043
|
exports.setCookie = setCookie;
|
|
7044
|
+
exports.setImgWidHeiBySrc = setImgWidHeiBySrc;
|
|
6669
7045
|
exports.setLocalStorage = setLocalStorage;
|
|
6670
7046
|
exports.setSessionStorage = setSessionStorage;
|
|
6671
7047
|
exports.throttle = throttle;
|