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.esm.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
|
*/
|
|
@@ -1121,7 +1121,7 @@ var isConstructor = !construct || fails(function () {
|
|
|
1121
1121
|
}) ? isConstructorLegacy : isConstructorModern;
|
|
1122
1122
|
|
|
1123
1123
|
var SPECIES$6 = wellKnownSymbol('species');
|
|
1124
|
-
var $Array$
|
|
1124
|
+
var $Array$3 = Array;
|
|
1125
1125
|
|
|
1126
1126
|
// a part of `ArraySpeciesCreate` abstract operation
|
|
1127
1127
|
// https://tc39.es/ecma262/#sec-arrayspeciescreate
|
|
@@ -1130,12 +1130,12 @@ var arraySpeciesConstructor = function (originalArray) {
|
|
|
1130
1130
|
if (isArray(originalArray)) {
|
|
1131
1131
|
C = originalArray.constructor;
|
|
1132
1132
|
// cross-realm fallback
|
|
1133
|
-
if (isConstructor(C) && (C === $Array$
|
|
1133
|
+
if (isConstructor(C) && (C === $Array$3 || isArray(C.prototype))) C = undefined;
|
|
1134
1134
|
else if (isObject(C)) {
|
|
1135
1135
|
C = C[SPECIES$6];
|
|
1136
1136
|
if (C === null) C = undefined;
|
|
1137
1137
|
}
|
|
1138
|
-
} return C === undefined ? $Array$
|
|
1138
|
+
} return C === undefined ? $Array$3 : C;
|
|
1139
1139
|
};
|
|
1140
1140
|
|
|
1141
1141
|
// `ArraySpeciesCreate` abstract operation
|
|
@@ -1397,7 +1397,7 @@ var NativeRegExp = global_1.RegExp;
|
|
|
1397
1397
|
var RegExpPrototype$2 = NativeRegExp.prototype;
|
|
1398
1398
|
var SyntaxError = global_1.SyntaxError;
|
|
1399
1399
|
var exec$1 = functionUncurryThis(RegExpPrototype$2.exec);
|
|
1400
|
-
var charAt$
|
|
1400
|
+
var charAt$6 = functionUncurryThis(''.charAt);
|
|
1401
1401
|
var replace$3 = functionUncurryThis(''.replace);
|
|
1402
1402
|
var stringIndexOf$2 = functionUncurryThis(''.indexOf);
|
|
1403
1403
|
var stringSlice$7 = functionUncurryThis(''.slice);
|
|
@@ -1426,9 +1426,9 @@ var handleDotAll = function (string) {
|
|
|
1426
1426
|
var brackets = false;
|
|
1427
1427
|
var chr;
|
|
1428
1428
|
for (; index <= length; index++) {
|
|
1429
|
-
chr = charAt$
|
|
1429
|
+
chr = charAt$6(string, index);
|
|
1430
1430
|
if (chr === '\\') {
|
|
1431
|
-
result += chr + charAt$
|
|
1431
|
+
result += chr + charAt$6(string, ++index);
|
|
1432
1432
|
continue;
|
|
1433
1433
|
}
|
|
1434
1434
|
if (!brackets && chr === '.') {
|
|
@@ -1455,9 +1455,9 @@ var handleNCG = function (string) {
|
|
|
1455
1455
|
var groupname = '';
|
|
1456
1456
|
var chr;
|
|
1457
1457
|
for (; index <= length; index++) {
|
|
1458
|
-
chr = charAt$
|
|
1458
|
+
chr = charAt$6(string, index);
|
|
1459
1459
|
if (chr === '\\') {
|
|
1460
|
-
chr = chr + charAt$
|
|
1460
|
+
chr = chr + charAt$6(string, ++index);
|
|
1461
1461
|
} else if (chr === ']') {
|
|
1462
1462
|
brackets = false;
|
|
1463
1463
|
} else if (!brackets) switch (true) {
|
|
@@ -1570,14 +1570,14 @@ setSpecies('RegExp');
|
|
|
1570
1570
|
|
|
1571
1571
|
|
|
1572
1572
|
|
|
1573
|
-
var getInternalState = internalState.get;
|
|
1573
|
+
var getInternalState$1 = internalState.get;
|
|
1574
1574
|
|
|
1575
1575
|
|
|
1576
1576
|
|
|
1577
1577
|
var nativeReplace = shared('native-string-replace', String.prototype.replace);
|
|
1578
1578
|
var nativeExec = RegExp.prototype.exec;
|
|
1579
1579
|
var patchedExec = nativeExec;
|
|
1580
|
-
var charAt$
|
|
1580
|
+
var charAt$5 = functionUncurryThis(''.charAt);
|
|
1581
1581
|
var indexOf = functionUncurryThis(''.indexOf);
|
|
1582
1582
|
var replace$2 = functionUncurryThis(''.replace);
|
|
1583
1583
|
var stringSlice$6 = functionUncurryThis(''.slice);
|
|
@@ -1600,7 +1600,7 @@ var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || rege
|
|
|
1600
1600
|
if (PATCH) {
|
|
1601
1601
|
patchedExec = function exec(string) {
|
|
1602
1602
|
var re = this;
|
|
1603
|
-
var state = getInternalState(re);
|
|
1603
|
+
var state = getInternalState$1(re);
|
|
1604
1604
|
var str = toString_1(string);
|
|
1605
1605
|
var raw = state.raw;
|
|
1606
1606
|
var result, reCopy, lastIndex, match, i, object, group;
|
|
@@ -1627,7 +1627,7 @@ if (PATCH) {
|
|
|
1627
1627
|
|
|
1628
1628
|
strCopy = stringSlice$6(str, re.lastIndex);
|
|
1629
1629
|
// Support anchored sticky behavior.
|
|
1630
|
-
if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$
|
|
1630
|
+
if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$5(str, re.lastIndex - 1) !== '\n')) {
|
|
1631
1631
|
source = '(?: ' + source + ')';
|
|
1632
1632
|
strCopy = ' ' + strCopy;
|
|
1633
1633
|
charsAdded++;
|
|
@@ -1684,7 +1684,7 @@ _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
|
|
|
1684
1684
|
exec: regexpExec
|
|
1685
1685
|
});
|
|
1686
1686
|
|
|
1687
|
-
var PROPER_FUNCTION_NAME = functionName.PROPER;
|
|
1687
|
+
var PROPER_FUNCTION_NAME$1 = functionName.PROPER;
|
|
1688
1688
|
|
|
1689
1689
|
|
|
1690
1690
|
|
|
@@ -1697,7 +1697,7 @@ var nativeToString = RegExpPrototype$1[TO_STRING];
|
|
|
1697
1697
|
|
|
1698
1698
|
var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
|
|
1699
1699
|
// FF44- RegExp#toString has a wrong name
|
|
1700
|
-
var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name != TO_STRING;
|
|
1700
|
+
var INCORRECT_NAME = PROPER_FUNCTION_NAME$1 && nativeToString.name != TO_STRING;
|
|
1701
1701
|
|
|
1702
1702
|
// `RegExp.prototype.toString` method
|
|
1703
1703
|
// https://tc39.es/ecma262/#sec-regexp.prototype.tostring
|
|
@@ -1791,7 +1791,7 @@ var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
|
|
|
1791
1791
|
if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
|
|
1792
1792
|
};
|
|
1793
1793
|
|
|
1794
|
-
var charAt$
|
|
1794
|
+
var charAt$4 = functionUncurryThis(''.charAt);
|
|
1795
1795
|
var charCodeAt$1 = functionUncurryThis(''.charCodeAt);
|
|
1796
1796
|
var stringSlice$5 = functionUncurryThis(''.slice);
|
|
1797
1797
|
|
|
@@ -1806,7 +1806,7 @@ var createMethod$3 = function (CONVERT_TO_STRING) {
|
|
|
1806
1806
|
return first < 0xD800 || first > 0xDBFF || position + 1 === size
|
|
1807
1807
|
|| (second = charCodeAt$1(S, position + 1)) < 0xDC00 || second > 0xDFFF
|
|
1808
1808
|
? CONVERT_TO_STRING
|
|
1809
|
-
? charAt$
|
|
1809
|
+
? charAt$4(S, position)
|
|
1810
1810
|
: first
|
|
1811
1811
|
: CONVERT_TO_STRING
|
|
1812
1812
|
? stringSlice$5(S, position, position + 2)
|
|
@@ -1823,12 +1823,12 @@ var stringMultibyte = {
|
|
|
1823
1823
|
charAt: createMethod$3(true)
|
|
1824
1824
|
};
|
|
1825
1825
|
|
|
1826
|
-
var charAt$
|
|
1826
|
+
var charAt$3 = stringMultibyte.charAt;
|
|
1827
1827
|
|
|
1828
1828
|
// `AdvanceStringIndex` abstract operation
|
|
1829
1829
|
// https://tc39.es/ecma262/#sec-advancestringindex
|
|
1830
1830
|
var advanceStringIndex = function (S, index, unicode) {
|
|
1831
|
-
return index + (unicode ? charAt$
|
|
1831
|
+
return index + (unicode ? charAt$3(S, index).length : 1);
|
|
1832
1832
|
};
|
|
1833
1833
|
|
|
1834
1834
|
var $TypeError$a = TypeError;
|
|
@@ -1929,7 +1929,7 @@ var functionApply = typeof Reflect == 'object' && Reflect.apply || (functionBind
|
|
|
1929
1929
|
});
|
|
1930
1930
|
|
|
1931
1931
|
var floor$1 = Math.floor;
|
|
1932
|
-
var charAt$
|
|
1932
|
+
var charAt$2 = functionUncurryThis(''.charAt);
|
|
1933
1933
|
var replace$1 = functionUncurryThis(''.replace);
|
|
1934
1934
|
var stringSlice$4 = functionUncurryThis(''.slice);
|
|
1935
1935
|
// eslint-disable-next-line redos/no-vulnerable -- safe
|
|
@@ -1948,7 +1948,7 @@ var getSubstitution = function (matched, str, position, captures, namedCaptures,
|
|
|
1948
1948
|
}
|
|
1949
1949
|
return replace$1(replacement, symbols, function (match, ch) {
|
|
1950
1950
|
var capture;
|
|
1951
|
-
switch (charAt$
|
|
1951
|
+
switch (charAt$2(ch, 0)) {
|
|
1952
1952
|
case '$': return '$';
|
|
1953
1953
|
case '&': return matched;
|
|
1954
1954
|
case '`': return stringSlice$4(str, 0, position);
|
|
@@ -1962,7 +1962,7 @@ var getSubstitution = function (matched, str, position, captures, namedCaptures,
|
|
|
1962
1962
|
if (n > m) {
|
|
1963
1963
|
var f = floor$1(n / 10);
|
|
1964
1964
|
if (f === 0) return match;
|
|
1965
|
-
if (f <= m) return captures[f - 1] === undefined ? charAt$
|
|
1965
|
+
if (f <= m) return captures[f - 1] === undefined ? charAt$2(ch, 1) : captures[f - 1] + charAt$2(ch, 1);
|
|
1966
1966
|
return match;
|
|
1967
1967
|
}
|
|
1968
1968
|
capture = captures[n - 1];
|
|
@@ -2197,7 +2197,7 @@ var arraySlice = functionUncurryThis([].slice);
|
|
|
2197
2197
|
var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('slice');
|
|
2198
2198
|
|
|
2199
2199
|
var SPECIES$2 = wellKnownSymbol('species');
|
|
2200
|
-
var $Array$
|
|
2200
|
+
var $Array$2 = Array;
|
|
2201
2201
|
var max$2 = Math.max;
|
|
2202
2202
|
|
|
2203
2203
|
// `Array.prototype.slice` method
|
|
@@ -2214,17 +2214,17 @@ _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 }, {
|
|
|
2214
2214
|
if (isArray(O)) {
|
|
2215
2215
|
Constructor = O.constructor;
|
|
2216
2216
|
// cross-realm fallback
|
|
2217
|
-
if (isConstructor(Constructor) && (Constructor === $Array$
|
|
2217
|
+
if (isConstructor(Constructor) && (Constructor === $Array$2 || isArray(Constructor.prototype))) {
|
|
2218
2218
|
Constructor = undefined;
|
|
2219
2219
|
} else if (isObject(Constructor)) {
|
|
2220
2220
|
Constructor = Constructor[SPECIES$2];
|
|
2221
2221
|
if (Constructor === null) Constructor = undefined;
|
|
2222
2222
|
}
|
|
2223
|
-
if (Constructor === $Array$
|
|
2223
|
+
if (Constructor === $Array$2 || Constructor === undefined) {
|
|
2224
2224
|
return arraySlice(O, k, fin);
|
|
2225
2225
|
}
|
|
2226
2226
|
}
|
|
2227
|
-
result = new (Constructor === undefined ? $Array$
|
|
2227
|
+
result = new (Constructor === undefined ? $Array$2 : Constructor)(max$2(fin - k, 0));
|
|
2228
2228
|
for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
|
|
2229
2229
|
result.length = n;
|
|
2230
2230
|
return result;
|
|
@@ -2405,20 +2405,20 @@ var stringTrim = {
|
|
|
2405
2405
|
var trim$1 = stringTrim.trim;
|
|
2406
2406
|
|
|
2407
2407
|
|
|
2408
|
-
var charAt = functionUncurryThis(''.charAt);
|
|
2408
|
+
var charAt$1 = functionUncurryThis(''.charAt);
|
|
2409
2409
|
var $parseFloat = global_1.parseFloat;
|
|
2410
2410
|
var Symbol$1 = global_1.Symbol;
|
|
2411
|
-
var ITERATOR$
|
|
2411
|
+
var ITERATOR$5 = Symbol$1 && Symbol$1.iterator;
|
|
2412
2412
|
var FORCED$2 = 1 / $parseFloat(whitespaces + '-0') !== -Infinity
|
|
2413
2413
|
// MS Edge 18- broken with boxed symbols
|
|
2414
|
-
|| (ITERATOR$
|
|
2414
|
+
|| (ITERATOR$5 && !fails(function () { $parseFloat(Object(ITERATOR$5)); }));
|
|
2415
2415
|
|
|
2416
2416
|
// `parseFloat` method
|
|
2417
2417
|
// https://tc39.es/ecma262/#sec-parsefloat-string
|
|
2418
2418
|
var numberParseFloat = FORCED$2 ? function parseFloat(string) {
|
|
2419
2419
|
var trimmedString = trim$1(toString_1(string));
|
|
2420
2420
|
var result = $parseFloat(trimmedString);
|
|
2421
|
-
return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;
|
|
2421
|
+
return result === 0 && charAt$1(trimmedString, 0) == '-' ? -0 : result;
|
|
2422
2422
|
} : $parseFloat;
|
|
2423
2423
|
|
|
2424
2424
|
// `parseFloat` method
|
|
@@ -2445,14 +2445,14 @@ var speciesConstructor = function (O, defaultConstructor) {
|
|
|
2445
2445
|
return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S);
|
|
2446
2446
|
};
|
|
2447
2447
|
|
|
2448
|
-
var $Array = Array;
|
|
2448
|
+
var $Array$1 = Array;
|
|
2449
2449
|
var max$1 = Math.max;
|
|
2450
2450
|
|
|
2451
2451
|
var arraySliceSimple = function (O, start, end) {
|
|
2452
2452
|
var length = lengthOfArrayLike(O);
|
|
2453
2453
|
var k = toAbsoluteIndex(start, length);
|
|
2454
2454
|
var fin = toAbsoluteIndex(end === undefined ? length : end, length);
|
|
2455
|
-
var result = $Array(max$1(fin - k, 0));
|
|
2455
|
+
var result = $Array$1(max$1(fin - k, 0));
|
|
2456
2456
|
for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
|
|
2457
2457
|
result.length = n;
|
|
2458
2458
|
return result;
|
|
@@ -3090,7 +3090,7 @@ var FORCED_PROMISE_CONSTRUCTOR$4 = promiseConstructorDetection.CONSTRUCTOR;
|
|
|
3090
3090
|
var NATIVE_PROMISE_REJECTION_EVENT = promiseConstructorDetection.REJECTION_EVENT;
|
|
3091
3091
|
var NATIVE_PROMISE_SUBCLASSING = promiseConstructorDetection.SUBCLASSING;
|
|
3092
3092
|
var getInternalPromiseState = internalState.getterFor(PROMISE);
|
|
3093
|
-
var setInternalState = internalState.set;
|
|
3093
|
+
var setInternalState$1 = internalState.set;
|
|
3094
3094
|
var NativePromisePrototype$1 = promiseNativeConstructor && promiseNativeConstructor.prototype;
|
|
3095
3095
|
var PromiseConstructor = promiseNativeConstructor;
|
|
3096
3096
|
var PromisePrototype = NativePromisePrototype$1;
|
|
@@ -3274,7 +3274,7 @@ if (FORCED_PROMISE_CONSTRUCTOR$4) {
|
|
|
3274
3274
|
|
|
3275
3275
|
// eslint-disable-next-line no-unused-vars -- required for `.length`
|
|
3276
3276
|
Internal = function Promise(executor) {
|
|
3277
|
-
setInternalState(this, {
|
|
3277
|
+
setInternalState$1(this, {
|
|
3278
3278
|
type: PROMISE,
|
|
3279
3279
|
done: false,
|
|
3280
3280
|
notified: false,
|
|
@@ -3351,18 +3351,18 @@ setSpecies(PROMISE);
|
|
|
3351
3351
|
|
|
3352
3352
|
var iterators = {};
|
|
3353
3353
|
|
|
3354
|
-
var ITERATOR$
|
|
3354
|
+
var ITERATOR$4 = wellKnownSymbol('iterator');
|
|
3355
3355
|
var ArrayPrototype = Array.prototype;
|
|
3356
3356
|
|
|
3357
3357
|
// check on default Array iterator
|
|
3358
3358
|
var isArrayIteratorMethod = function (it) {
|
|
3359
|
-
return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR$
|
|
3359
|
+
return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR$4] === it);
|
|
3360
3360
|
};
|
|
3361
3361
|
|
|
3362
|
-
var ITERATOR$
|
|
3362
|
+
var ITERATOR$3 = wellKnownSymbol('iterator');
|
|
3363
3363
|
|
|
3364
3364
|
var getIteratorMethod = function (it) {
|
|
3365
|
-
if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR$
|
|
3365
|
+
if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR$3)
|
|
3366
3366
|
|| getMethod(it, '@@iterator')
|
|
3367
3367
|
|| iterators[classof(it)];
|
|
3368
3368
|
};
|
|
@@ -3453,7 +3453,7 @@ var iterate = function (iterable, unboundFunction, options) {
|
|
|
3453
3453
|
} return new Result(false);
|
|
3454
3454
|
};
|
|
3455
3455
|
|
|
3456
|
-
var ITERATOR = wellKnownSymbol('iterator');
|
|
3456
|
+
var ITERATOR$2 = wellKnownSymbol('iterator');
|
|
3457
3457
|
var SAFE_CLOSING = false;
|
|
3458
3458
|
|
|
3459
3459
|
try {
|
|
@@ -3466,7 +3466,7 @@ try {
|
|
|
3466
3466
|
SAFE_CLOSING = true;
|
|
3467
3467
|
}
|
|
3468
3468
|
};
|
|
3469
|
-
iteratorWithReturn[ITERATOR] = function () {
|
|
3469
|
+
iteratorWithReturn[ITERATOR$2] = function () {
|
|
3470
3470
|
return this;
|
|
3471
3471
|
};
|
|
3472
3472
|
// eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
|
|
@@ -3478,7 +3478,7 @@ var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
|
|
|
3478
3478
|
var ITERATION_SUPPORT = false;
|
|
3479
3479
|
try {
|
|
3480
3480
|
var object = {};
|
|
3481
|
-
object[ITERATOR] = function () {
|
|
3481
|
+
object[ITERATOR$2] = function () {
|
|
3482
3482
|
return {
|
|
3483
3483
|
next: function () {
|
|
3484
3484
|
return { done: ITERATION_SUPPORT = true };
|
|
@@ -3973,6 +3973,236 @@ _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
|
|
|
3973
3973
|
}
|
|
3974
3974
|
});
|
|
3975
3975
|
|
|
3976
|
+
// call something on iterator step with safe closing on error
|
|
3977
|
+
var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
|
|
3978
|
+
try {
|
|
3979
|
+
return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
|
|
3980
|
+
} catch (error) {
|
|
3981
|
+
iteratorClose(iterator, 'throw', error);
|
|
3982
|
+
}
|
|
3983
|
+
};
|
|
3984
|
+
|
|
3985
|
+
var $Array = Array;
|
|
3986
|
+
|
|
3987
|
+
// `Array.from` method implementation
|
|
3988
|
+
// https://tc39.es/ecma262/#sec-array.from
|
|
3989
|
+
var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
|
|
3990
|
+
var O = toObject(arrayLike);
|
|
3991
|
+
var IS_CONSTRUCTOR = isConstructor(this);
|
|
3992
|
+
var argumentsLength = arguments.length;
|
|
3993
|
+
var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
|
|
3994
|
+
var mapping = mapfn !== undefined;
|
|
3995
|
+
if (mapping) mapfn = functionBindContext(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
|
|
3996
|
+
var iteratorMethod = getIteratorMethod(O);
|
|
3997
|
+
var index = 0;
|
|
3998
|
+
var length, result, step, iterator, next, value;
|
|
3999
|
+
// if the target is not iterable or it's an array with the default iterator - use a simple case
|
|
4000
|
+
if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
|
|
4001
|
+
iterator = getIterator(O, iteratorMethod);
|
|
4002
|
+
next = iterator.next;
|
|
4003
|
+
result = IS_CONSTRUCTOR ? new this() : [];
|
|
4004
|
+
for (;!(step = functionCall(next, iterator)).done; index++) {
|
|
4005
|
+
value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
|
|
4006
|
+
createProperty(result, index, value);
|
|
4007
|
+
}
|
|
4008
|
+
} else {
|
|
4009
|
+
length = lengthOfArrayLike(O);
|
|
4010
|
+
result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
|
|
4011
|
+
for (;length > index; index++) {
|
|
4012
|
+
value = mapping ? mapfn(O[index], index) : O[index];
|
|
4013
|
+
createProperty(result, index, value);
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
result.length = index;
|
|
4017
|
+
return result;
|
|
4018
|
+
};
|
|
4019
|
+
|
|
4020
|
+
var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
|
|
4021
|
+
// eslint-disable-next-line es/no-array-from -- required for testing
|
|
4022
|
+
Array.from(iterable);
|
|
4023
|
+
});
|
|
4024
|
+
|
|
4025
|
+
// `Array.from` method
|
|
4026
|
+
// https://tc39.es/ecma262/#sec-array.from
|
|
4027
|
+
_export({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
|
|
4028
|
+
from: arrayFrom
|
|
4029
|
+
});
|
|
4030
|
+
|
|
4031
|
+
var ITERATOR$1 = wellKnownSymbol('iterator');
|
|
4032
|
+
var BUGGY_SAFARI_ITERATORS$1 = false;
|
|
4033
|
+
|
|
4034
|
+
// `%IteratorPrototype%` object
|
|
4035
|
+
// https://tc39.es/ecma262/#sec-%iteratorprototype%-object
|
|
4036
|
+
var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator;
|
|
4037
|
+
|
|
4038
|
+
/* eslint-disable es/no-array-prototype-keys -- safe */
|
|
4039
|
+
if ([].keys) {
|
|
4040
|
+
arrayIterator = [].keys();
|
|
4041
|
+
// Safari 8 has buggy iterators w/o `next`
|
|
4042
|
+
if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true;
|
|
4043
|
+
else {
|
|
4044
|
+
PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator));
|
|
4045
|
+
if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype;
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
|
|
4049
|
+
var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails(function () {
|
|
4050
|
+
var test = {};
|
|
4051
|
+
// FF44- legacy iterators case
|
|
4052
|
+
return IteratorPrototype$2[ITERATOR$1].call(test) !== test;
|
|
4053
|
+
});
|
|
4054
|
+
|
|
4055
|
+
if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {};
|
|
4056
|
+
|
|
4057
|
+
// `%IteratorPrototype%[@@iterator]()` method
|
|
4058
|
+
// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
|
|
4059
|
+
if (!isCallable(IteratorPrototype$2[ITERATOR$1])) {
|
|
4060
|
+
defineBuiltIn(IteratorPrototype$2, ITERATOR$1, function () {
|
|
4061
|
+
return this;
|
|
4062
|
+
});
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
var iteratorsCore = {
|
|
4066
|
+
IteratorPrototype: IteratorPrototype$2,
|
|
4067
|
+
BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1
|
|
4068
|
+
};
|
|
4069
|
+
|
|
4070
|
+
var IteratorPrototype$1 = iteratorsCore.IteratorPrototype;
|
|
4071
|
+
|
|
4072
|
+
|
|
4073
|
+
|
|
4074
|
+
|
|
4075
|
+
|
|
4076
|
+
var returnThis$1 = function () { return this; };
|
|
4077
|
+
|
|
4078
|
+
var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) {
|
|
4079
|
+
var TO_STRING_TAG = NAME + ' Iterator';
|
|
4080
|
+
IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) });
|
|
4081
|
+
setToStringTag(IteratorConstructor, TO_STRING_TAG, false);
|
|
4082
|
+
iterators[TO_STRING_TAG] = returnThis$1;
|
|
4083
|
+
return IteratorConstructor;
|
|
4084
|
+
};
|
|
4085
|
+
|
|
4086
|
+
var PROPER_FUNCTION_NAME = functionName.PROPER;
|
|
4087
|
+
var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
|
|
4088
|
+
var IteratorPrototype = iteratorsCore.IteratorPrototype;
|
|
4089
|
+
var BUGGY_SAFARI_ITERATORS = iteratorsCore.BUGGY_SAFARI_ITERATORS;
|
|
4090
|
+
var ITERATOR = wellKnownSymbol('iterator');
|
|
4091
|
+
var KEYS = 'keys';
|
|
4092
|
+
var VALUES = 'values';
|
|
4093
|
+
var ENTRIES = 'entries';
|
|
4094
|
+
|
|
4095
|
+
var returnThis = function () { return this; };
|
|
4096
|
+
|
|
4097
|
+
var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) {
|
|
4098
|
+
iteratorCreateConstructor(IteratorConstructor, NAME, next);
|
|
4099
|
+
|
|
4100
|
+
var getIterationMethod = function (KIND) {
|
|
4101
|
+
if (KIND === DEFAULT && defaultIterator) return defaultIterator;
|
|
4102
|
+
if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND];
|
|
4103
|
+
switch (KIND) {
|
|
4104
|
+
case KEYS: return function keys() { return new IteratorConstructor(this, KIND); };
|
|
4105
|
+
case VALUES: return function values() { return new IteratorConstructor(this, KIND); };
|
|
4106
|
+
case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); };
|
|
4107
|
+
} return function () { return new IteratorConstructor(this); };
|
|
4108
|
+
};
|
|
4109
|
+
|
|
4110
|
+
var TO_STRING_TAG = NAME + ' Iterator';
|
|
4111
|
+
var INCORRECT_VALUES_NAME = false;
|
|
4112
|
+
var IterablePrototype = Iterable.prototype;
|
|
4113
|
+
var nativeIterator = IterablePrototype[ITERATOR]
|
|
4114
|
+
|| IterablePrototype['@@iterator']
|
|
4115
|
+
|| DEFAULT && IterablePrototype[DEFAULT];
|
|
4116
|
+
var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT);
|
|
4117
|
+
var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator;
|
|
4118
|
+
var CurrentIteratorPrototype, methods, KEY;
|
|
4119
|
+
|
|
4120
|
+
// fix native
|
|
4121
|
+
if (anyNativeIterator) {
|
|
4122
|
+
CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable()));
|
|
4123
|
+
if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) {
|
|
4124
|
+
if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) {
|
|
4125
|
+
if (objectSetPrototypeOf) {
|
|
4126
|
+
objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype);
|
|
4127
|
+
} else if (!isCallable(CurrentIteratorPrototype[ITERATOR])) {
|
|
4128
|
+
defineBuiltIn(CurrentIteratorPrototype, ITERATOR, returnThis);
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4131
|
+
// Set @@toStringTag to native iterators
|
|
4132
|
+
setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true);
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
// fix Array.prototype.{ values, @@iterator }.name in V8 / FF
|
|
4137
|
+
if (PROPER_FUNCTION_NAME && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) {
|
|
4138
|
+
if (CONFIGURABLE_FUNCTION_NAME) {
|
|
4139
|
+
createNonEnumerableProperty(IterablePrototype, 'name', VALUES);
|
|
4140
|
+
} else {
|
|
4141
|
+
INCORRECT_VALUES_NAME = true;
|
|
4142
|
+
defaultIterator = function values() { return functionCall(nativeIterator, this); };
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4146
|
+
// export additional methods
|
|
4147
|
+
if (DEFAULT) {
|
|
4148
|
+
methods = {
|
|
4149
|
+
values: getIterationMethod(VALUES),
|
|
4150
|
+
keys: IS_SET ? defaultIterator : getIterationMethod(KEYS),
|
|
4151
|
+
entries: getIterationMethod(ENTRIES)
|
|
4152
|
+
};
|
|
4153
|
+
if (FORCED) for (KEY in methods) {
|
|
4154
|
+
if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
|
|
4155
|
+
defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
|
|
4156
|
+
}
|
|
4157
|
+
} else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
|
|
4158
|
+
}
|
|
4159
|
+
|
|
4160
|
+
// define iterator
|
|
4161
|
+
if (IterablePrototype[ITERATOR] !== defaultIterator) {
|
|
4162
|
+
defineBuiltIn(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT });
|
|
4163
|
+
}
|
|
4164
|
+
iterators[NAME] = defaultIterator;
|
|
4165
|
+
|
|
4166
|
+
return methods;
|
|
4167
|
+
};
|
|
4168
|
+
|
|
4169
|
+
// `CreateIterResultObject` abstract operation
|
|
4170
|
+
// https://tc39.es/ecma262/#sec-createiterresultobject
|
|
4171
|
+
var createIterResultObject = function (value, done) {
|
|
4172
|
+
return { value: value, done: done };
|
|
4173
|
+
};
|
|
4174
|
+
|
|
4175
|
+
var charAt = stringMultibyte.charAt;
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
|
|
4181
|
+
var STRING_ITERATOR = 'String Iterator';
|
|
4182
|
+
var setInternalState = internalState.set;
|
|
4183
|
+
var getInternalState = internalState.getterFor(STRING_ITERATOR);
|
|
4184
|
+
|
|
4185
|
+
// `String.prototype[@@iterator]` method
|
|
4186
|
+
// https://tc39.es/ecma262/#sec-string.prototype-@@iterator
|
|
4187
|
+
iteratorDefine(String, 'String', function (iterated) {
|
|
4188
|
+
setInternalState(this, {
|
|
4189
|
+
type: STRING_ITERATOR,
|
|
4190
|
+
string: toString_1(iterated),
|
|
4191
|
+
index: 0
|
|
4192
|
+
});
|
|
4193
|
+
// `%StringIteratorPrototype%.next` method
|
|
4194
|
+
// https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
|
|
4195
|
+
}, function next() {
|
|
4196
|
+
var state = getInternalState(this);
|
|
4197
|
+
var string = state.string;
|
|
4198
|
+
var index = state.index;
|
|
4199
|
+
var point;
|
|
4200
|
+
if (index >= string.length) return createIterResultObject(undefined, true);
|
|
4201
|
+
point = charAt(string, index);
|
|
4202
|
+
state.index += point.length;
|
|
4203
|
+
return createIterResultObject(point, false);
|
|
4204
|
+
});
|
|
4205
|
+
|
|
3976
4206
|
/*! *****************************************************************************
|
|
3977
4207
|
Copyright (c) Microsoft Corporation.
|
|
3978
4208
|
|
|
@@ -4128,34 +4358,32 @@ function getQueryParam(param) {
|
|
|
4128
4358
|
return '';
|
|
4129
4359
|
}
|
|
4130
4360
|
/**
|
|
4131
|
-
*
|
|
4361
|
+
* Returns the value of the specified query parameter in the input URL.
|
|
4132
4362
|
*
|
|
4363
|
+
* @example
|
|
4133
4364
|
* ```
|
|
4134
|
-
* getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3'); // 3
|
|
4135
|
-
* getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4'); // 4
|
|
4365
|
+
* getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3'); // Returns '3'
|
|
4366
|
+
* getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4'); // Returns '4'
|
|
4136
4367
|
* ```
|
|
4137
4368
|
*
|
|
4138
|
-
* @param {string} url URL string.
|
|
4139
|
-
* @param {string} param
|
|
4140
|
-
* @returns {string} value
|
|
4369
|
+
* @param {string} url The URL string.
|
|
4370
|
+
* @param {string} param The query parameter to retrieve the value for.
|
|
4371
|
+
* @returns {string|string[]} The value of the specified query parameter, or an empty string if the parameter is not found.
|
|
4141
4372
|
* @category URL
|
|
4142
4373
|
*/
|
|
4143
4374
|
function getUrlParam(url, param) {
|
|
4144
4375
|
var result = {};
|
|
4145
|
-
|
|
4146
|
-
url.replace(/\??(\w+)=([^&]*)&?/g, function (a, k, v) {
|
|
4376
|
+
url.replace(/\??(\w+)=([^&]*)&?/g, function (_, k, v) {
|
|
4147
4377
|
if (result[k] !== undefined) {
|
|
4148
4378
|
var t = result[k];
|
|
4379
|
+
// Cast `t` to `string[]` to ensure that `concat` receives an array
|
|
4149
4380
|
result[k] = [].concat(t, v);
|
|
4150
4381
|
} else {
|
|
4151
4382
|
result[k] = v;
|
|
4152
4383
|
}
|
|
4384
|
+
// Return an empty string to satisfy the signature of the replace method
|
|
4385
|
+
return '';
|
|
4153
4386
|
});
|
|
4154
|
-
// if (param === undefined) {
|
|
4155
|
-
// return result;
|
|
4156
|
-
// } else {
|
|
4157
|
-
// return result[param] || '';
|
|
4158
|
-
// }
|
|
4159
4387
|
return result[param] || '';
|
|
4160
4388
|
}
|
|
4161
4389
|
/**
|
|
@@ -4437,8 +4665,8 @@ function generateRndNum(n) {
|
|
|
4437
4665
|
return ret;
|
|
4438
4666
|
}
|
|
4439
4667
|
/**
|
|
4440
|
-
*
|
|
4441
|
-
*
|
|
4668
|
+
* 根据时间生成唯一标志的数字 mGenerateUniqueNum() => 1538324722364123
|
|
4669
|
+
*
|
|
4442
4670
|
* @param {number} n 随机数的长度
|
|
4443
4671
|
* @category Util
|
|
4444
4672
|
*/
|
|
@@ -4452,8 +4680,8 @@ function generateUniqueNum(n) {
|
|
|
4452
4680
|
return now + rnd;
|
|
4453
4681
|
}
|
|
4454
4682
|
/**
|
|
4455
|
-
*
|
|
4456
|
-
*
|
|
4683
|
+
* 浮点数转为百分比 0.2 => 20%
|
|
4684
|
+
*
|
|
4457
4685
|
* @param {number} num 浮点数
|
|
4458
4686
|
* @param {number} fixSize 保留几位浮点数
|
|
4459
4687
|
* @category Util
|
|
@@ -4471,8 +4699,8 @@ function floatToPercent(num, fixSize) {
|
|
|
4471
4699
|
return "".concat(ret, "%");
|
|
4472
4700
|
}
|
|
4473
4701
|
/**
|
|
4474
|
-
*
|
|
4475
|
-
*
|
|
4702
|
+
* 浮点数保留指定位
|
|
4703
|
+
*
|
|
4476
4704
|
* @category Util
|
|
4477
4705
|
*/
|
|
4478
4706
|
function floatFixed(num, size) {
|
|
@@ -4482,9 +4710,9 @@ function floatFixed(num, size) {
|
|
|
4482
4710
|
return parseFloat(num).toFixed(size);
|
|
4483
4711
|
}
|
|
4484
4712
|
/**
|
|
4485
|
-
*
|
|
4486
|
-
*
|
|
4487
|
-
* @category
|
|
4713
|
+
* 阻止冒泡
|
|
4714
|
+
*
|
|
4715
|
+
* @category Event
|
|
4488
4716
|
*/
|
|
4489
4717
|
function cancelBubble(e) {
|
|
4490
4718
|
var ev = e || window.event;
|
|
@@ -4595,8 +4823,6 @@ function throttle(func, wait, options) {
|
|
|
4595
4823
|
options = {};
|
|
4596
4824
|
}
|
|
4597
4825
|
options = Object.assign({}, options);
|
|
4598
|
-
// timeout: setTimeout Handle
|
|
4599
|
-
// previous: 上次时间戳
|
|
4600
4826
|
var context = null;
|
|
4601
4827
|
var args = null;
|
|
4602
4828
|
var timeout = null;
|
|
@@ -4606,7 +4832,7 @@ function throttle(func, wait, options) {
|
|
|
4606
4832
|
var later = function later() {
|
|
4607
4833
|
previous = options.leading === false ? 0 : mNow();
|
|
4608
4834
|
timeout = null;
|
|
4609
|
-
result = func.apply(
|
|
4835
|
+
result = func.apply(this, args);
|
|
4610
4836
|
if (!timeout) {
|
|
4611
4837
|
context = args = null;
|
|
4612
4838
|
}
|
|
@@ -4634,7 +4860,7 @@ function throttle(func, wait, options) {
|
|
|
4634
4860
|
context = args = null;
|
|
4635
4861
|
}
|
|
4636
4862
|
} else if (!timeout && options.trailing !== false) {
|
|
4637
|
-
timeout = setTimeout(later, remaining);
|
|
4863
|
+
timeout = setTimeout(later.bind(context), remaining);
|
|
4638
4864
|
}
|
|
4639
4865
|
return result;
|
|
4640
4866
|
};
|
|
@@ -4657,7 +4883,7 @@ function debounce(func, wait, immediate) {
|
|
|
4657
4883
|
var timeout = null;
|
|
4658
4884
|
var timestamp = null;
|
|
4659
4885
|
var args = null;
|
|
4660
|
-
var result =
|
|
4886
|
+
var result = null;
|
|
4661
4887
|
var later = function later() {
|
|
4662
4888
|
var last = mNow() - timestamp;
|
|
4663
4889
|
if (last < wait && last >= 0) {
|
|
@@ -4776,37 +5002,26 @@ function getFriendlyInterval(start, end, options) {
|
|
|
4776
5002
|
*/
|
|
4777
5003
|
function isNumber(num, options) {
|
|
4778
5004
|
if (options === void 0) {
|
|
4779
|
-
options = {
|
|
4780
|
-
isNaNAsNumber: false,
|
|
4781
|
-
isUnFiniteAsNumber: false
|
|
4782
|
-
};
|
|
5005
|
+
options = {};
|
|
4783
5006
|
}
|
|
4784
|
-
var _a =
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
isNaNAsNumber = _a.isNaNAsNumber,
|
|
4789
|
-
isUnFiniteAsNumber = _a.isUnFiniteAsNumber;
|
|
4790
|
-
var ret = true;
|
|
4791
|
-
// 数字类型
|
|
5007
|
+
var _a = options.isNaNAsNumber,
|
|
5008
|
+
isNaNAsNumber = _a === void 0 ? false : _a,
|
|
5009
|
+
_b = options.isFiniteAsNumber,
|
|
5010
|
+
isFiniteAsNumber = _b === void 0 ? false : _b;
|
|
4792
5011
|
if (typeof num !== 'number') {
|
|
4793
|
-
|
|
5012
|
+
return false;
|
|
4794
5013
|
}
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
// console.log('1333');
|
|
4798
|
-
ret = false;
|
|
5014
|
+
if (!isFiniteAsNumber && !isFinite(num)) {
|
|
5015
|
+
return false;
|
|
4799
5016
|
}
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
// console.log('2333');
|
|
4803
|
-
ret = false;
|
|
5017
|
+
if (!isNaNAsNumber && isNaN(num)) {
|
|
5018
|
+
return false;
|
|
4804
5019
|
}
|
|
4805
|
-
return
|
|
5020
|
+
return true;
|
|
4806
5021
|
}
|
|
4807
5022
|
/**
|
|
4808
|
-
*
|
|
4809
|
-
*
|
|
5023
|
+
* 执行有效函数
|
|
5024
|
+
*
|
|
4810
5025
|
* @param {function} fn 等待被执行的未知是否有效的函数
|
|
4811
5026
|
* @category Util
|
|
4812
5027
|
*/
|
|
@@ -4844,7 +5059,7 @@ function doFn(fn) {
|
|
|
4844
5059
|
* ```
|
|
4845
5060
|
*
|
|
4846
5061
|
* @param {string} key 键
|
|
4847
|
-
* @returns {
|
|
5062
|
+
* @returns {void} 返回值
|
|
4848
5063
|
* @category Cache Data
|
|
4849
5064
|
*/
|
|
4850
5065
|
function setSessionStorage(key, value) {
|
|
@@ -4914,7 +5129,7 @@ function getSessionStorage(key) {
|
|
|
4914
5129
|
* ```
|
|
4915
5130
|
*
|
|
4916
5131
|
* @param {string} key 键
|
|
4917
|
-
* @returns {
|
|
5132
|
+
* @returns {void} 返回值
|
|
4918
5133
|
* @category Cache Data
|
|
4919
5134
|
*/
|
|
4920
5135
|
function setLocalStorage(key, value) {
|
|
@@ -5193,8 +5408,8 @@ function loadScript(url, options) {
|
|
|
5193
5408
|
});
|
|
5194
5409
|
}
|
|
5195
5410
|
/**
|
|
5196
|
-
*
|
|
5197
|
-
*
|
|
5411
|
+
* 获取时间戳
|
|
5412
|
+
*
|
|
5198
5413
|
* @category Util
|
|
5199
5414
|
*/
|
|
5200
5415
|
function mNow() {
|
|
@@ -5220,11 +5435,11 @@ function mNow() {
|
|
|
5220
5435
|
*/
|
|
5221
5436
|
function setCookie(name, value, days, domain) {
|
|
5222
5437
|
var domainParts, expires;
|
|
5223
|
-
|
|
5438
|
+
// let date: any;
|
|
5224
5439
|
if (days) {
|
|
5225
|
-
date = new Date();
|
|
5440
|
+
var date = new Date();
|
|
5226
5441
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
5227
|
-
expires = '; expires=' + date.
|
|
5442
|
+
expires = '; expires=' + date.toUTCString();
|
|
5228
5443
|
} else {
|
|
5229
5444
|
expires = '';
|
|
5230
5445
|
}
|
|
@@ -5869,14 +6084,50 @@ function getBrowserInfo() {
|
|
|
5869
6084
|
}
|
|
5870
6085
|
}
|
|
5871
6086
|
/**
|
|
5872
|
-
*
|
|
5873
|
-
*
|
|
6087
|
+
* 去除 HTML 标签
|
|
6088
|
+
*
|
|
5874
6089
|
* @param {string} str 带html标签的字符串
|
|
5875
6090
|
* @returns {string} 字符串
|
|
5876
6091
|
* @category Util
|
|
5877
6092
|
*/
|
|
5878
|
-
function clearHtml(str) {
|
|
5879
|
-
|
|
6093
|
+
function clearHtml(str, options) {
|
|
6094
|
+
if (options === void 0) {
|
|
6095
|
+
options = {};
|
|
6096
|
+
}
|
|
6097
|
+
var _a = options.removeNewLine,
|
|
6098
|
+
removeNewLine = _a === void 0 ? false : _a;
|
|
6099
|
+
var ret = '';
|
|
6100
|
+
if (str) {
|
|
6101
|
+
ret = str.replace(/<\/?.+?>/g, '');
|
|
6102
|
+
if (removeNewLine) {
|
|
6103
|
+
ret = ret.replace(/[\r\n]/g, '');
|
|
6104
|
+
}
|
|
6105
|
+
}
|
|
6106
|
+
return ret;
|
|
6107
|
+
// return str.replace(/<\/?.+?>/g, '').replace(/[\r\n]/g, '');
|
|
6108
|
+
}
|
|
6109
|
+
/**
|
|
6110
|
+
* Sanitizes user input to prevent XSS attacks
|
|
6111
|
+
*
|
|
6112
|
+
* @param input - The input string to sanitize
|
|
6113
|
+
* @returns The sanitized input string
|
|
6114
|
+
*/
|
|
6115
|
+
function sanitizeInput(input) {
|
|
6116
|
+
var regex = /[&<>"'/]/g;
|
|
6117
|
+
var replacements = {
|
|
6118
|
+
'&': '&',
|
|
6119
|
+
'<': '<',
|
|
6120
|
+
'>': '>',
|
|
6121
|
+
'"': '"',
|
|
6122
|
+
'\'': ''',
|
|
6123
|
+
'/': '/'
|
|
6124
|
+
};
|
|
6125
|
+
if (typeof input !== 'string') {
|
|
6126
|
+
console.error('Input must be a string');
|
|
6127
|
+
}
|
|
6128
|
+
return input.replace(regex, function (match) {
|
|
6129
|
+
return replacements[match];
|
|
6130
|
+
});
|
|
5880
6131
|
}
|
|
5881
6132
|
/**
|
|
5882
6133
|
* 截取字符串,中文算 2 个字节
|
|
@@ -6279,15 +6530,12 @@ function isNonEmptyArray(arr) {
|
|
|
6279
6530
|
function isValidData(data, attributes, validValue) {
|
|
6280
6531
|
var ret = false;
|
|
6281
6532
|
var foundRet = attributes.reduce(function (foundValue, curr) {
|
|
6282
|
-
if (foundValue
|
|
6283
|
-
|
|
6533
|
+
if (foundValue && Object.prototype.hasOwnProperty.call(foundValue, curr)) {
|
|
6534
|
+
return foundValue[curr];
|
|
6284
6535
|
} else {
|
|
6285
6536
|
return Object.create(null);
|
|
6286
6537
|
}
|
|
6287
|
-
// console.log('foundValue', foundValue);
|
|
6288
|
-
return foundValue;
|
|
6289
6538
|
}, data);
|
|
6290
|
-
// console.log('foundRet', foundRet);
|
|
6291
6539
|
if (foundRet === validValue) {
|
|
6292
6540
|
ret = true;
|
|
6293
6541
|
}
|
|
@@ -6604,5 +6852,129 @@ function getUrlFileType(url) {
|
|
|
6604
6852
|
// }
|
|
6605
6853
|
return ret;
|
|
6606
6854
|
}
|
|
6855
|
+
/**
|
|
6856
|
+
* Sets the width and height of all images on the page based on their `src` attribute.
|
|
6857
|
+
* The `src` attribute should contain `width` and/or `height` values in the format "width=100" or "height=100".
|
|
6858
|
+
* If jQuery is available, this function uses jQuery to select the images. Otherwise, it uses pure JavaScript.
|
|
6859
|
+
*
|
|
6860
|
+
* @example
|
|
6861
|
+
* ```
|
|
6862
|
+
* // Example images with `src` attributes containing `width` and/or `height` values
|
|
6863
|
+
* const img1 = document.createElement('img');
|
|
6864
|
+
* img1.setAttribute('src', 'https://example.com/example.png?width=2233&height=111');
|
|
6865
|
+
* document.body.appendChild(img1);
|
|
6866
|
+
*
|
|
6867
|
+
* const img2 = document.createElement('img');
|
|
6868
|
+
* img2.setAttribute('src', 'https://example.com/example.png?width=100%&height=auto');
|
|
6869
|
+
* document.body.appendChild(img2);
|
|
6870
|
+
* ```
|
|
6871
|
+
*
|
|
6872
|
+
* @returns {boolean} - Returns `true` if images were found and their dimensions were set, otherwise `false`.
|
|
6873
|
+
*/
|
|
6874
|
+
function setImgWidHeiBySrc() {
|
|
6875
|
+
// Use jQuery if available, otherwise fall back to pure JavaScript
|
|
6876
|
+
var $ = window.jQuery || window.$;
|
|
6877
|
+
if ($) {
|
|
6878
|
+
// Use jQuery to select all images on the page
|
|
6879
|
+
var images = $('img');
|
|
6880
|
+
if (!(images && images.length)) return false;
|
|
6881
|
+
images.each(function () {
|
|
6882
|
+
var $this = $(this);
|
|
6883
|
+
if (!$this) return;
|
|
6884
|
+
// Get the `src` attribute of the image
|
|
6885
|
+
var src = $this.attr('src');
|
|
6886
|
+
var canMatch = src && typeof src === 'string' && src.length;
|
|
6887
|
+
if (!canMatch) return;
|
|
6888
|
+
// Use regular expressions to extract the `width` and `height` values from the `src` attribute
|
|
6889
|
+
var width = src.match(/width=([0-9]+[a-z%]*)/);
|
|
6890
|
+
var height = src.match(/height=([0-9]+[a-z%]*)/);
|
|
6891
|
+
// Set the width and height of the image using jQuery's `width()` and `height()` methods
|
|
6892
|
+
if (width && isNonEmptyArray(width) && width[1]) $this.width(width[1]);
|
|
6893
|
+
if (height && isNonEmptyArray(height) && height[1]) $this.height(height[1]);
|
|
6894
|
+
});
|
|
6895
|
+
return true;
|
|
6896
|
+
} else {
|
|
6897
|
+
// Use pure JavaScript to select all images on the page
|
|
6898
|
+
var images = document.getElementsByTagName('img');
|
|
6899
|
+
if (images.length > 0) {
|
|
6900
|
+
// Loop through each image and set its width and height based on the `src` attribute
|
|
6901
|
+
Array.from(images).forEach(function (img) {
|
|
6902
|
+
var $this = img;
|
|
6903
|
+
if (!$this) return;
|
|
6904
|
+
// Get the `src` attribute of the image
|
|
6905
|
+
var src = $this.getAttribute('src');
|
|
6906
|
+
var canMatch = src && typeof src === 'string' && src.length;
|
|
6907
|
+
if (!canMatch) return;
|
|
6908
|
+
// Use regular expressions to extract the `width` and `height` values from the `src` attribute
|
|
6909
|
+
var width = src.match(/width=([0-9]+[a-z%]*)/);
|
|
6910
|
+
var height = src.match(/height=([0-9]+[a-z%]*)/);
|
|
6911
|
+
// Set the width and height of the image using the `style.width` and `style.height` properties
|
|
6912
|
+
if (width && isNonEmptyArray(width) && width[1]) $this.style.width = width[1];
|
|
6913
|
+
if (height && isNonEmptyArray(height) && height[1]) $this.style.height = height[1];
|
|
6914
|
+
});
|
|
6915
|
+
return true;
|
|
6916
|
+
}
|
|
6917
|
+
}
|
|
6918
|
+
return false;
|
|
6919
|
+
}
|
|
6920
|
+
/**
|
|
6921
|
+
* Generate the inline style string from the given parameters, First parameter is the ClassNames, Second parameter is the style array.
|
|
6922
|
+
*
|
|
6923
|
+
* @example
|
|
6924
|
+
* ```js
|
|
6925
|
+
* console.log(genStyleString('a', [ 'color:red' ])); // '.a{color:red;}'
|
|
6926
|
+
* console.log(genStyleString('b', [ 'color:red', 'font-size:12px' ])); // '.b{color:red;font-size:12px;}'
|
|
6927
|
+
* ```
|
|
6928
|
+
*
|
|
6929
|
+
* @param {string} className
|
|
6930
|
+
* @param {Array} styleArray
|
|
6931
|
+
* @returns {string} Return the inline style string.
|
|
6932
|
+
* @category DOM
|
|
6933
|
+
*/
|
|
6934
|
+
function genStyleString(className, styleArray) {
|
|
6935
|
+
var style = '';
|
|
6936
|
+
if (styleArray && styleArray.length > 0) {
|
|
6937
|
+
// It's wrong. Last item will not include `;`.
|
|
6938
|
+
// style = styleArray.join(';');
|
|
6939
|
+
style = styleArray.join(';') + ';';
|
|
6940
|
+
}
|
|
6941
|
+
return ".".concat(className, "{").concat(style, "}");
|
|
6942
|
+
}
|
|
6943
|
+
/**
|
|
6944
|
+
* Load the image from the given url.
|
|
6945
|
+
* The target image will be loaded in the background, and the Promise status will change after the image is loaded.
|
|
6946
|
+
* If the image fails to load, the Promise status will change to `reject`.
|
|
6947
|
+
* If the image is loaded successfully, the Promise status will change to `resolve`.
|
|
6948
|
+
* If the image is loaded successfully, the Promise will return the image object.
|
|
6949
|
+
* If the image fails to load, the Promise will return the error object.
|
|
6950
|
+
* The method will help Web to preload the image. And the image will be cached by the browser.
|
|
6951
|
+
* We can use it to implement the lazy loading of images.
|
|
6952
|
+
* The method will not add the image to the DOM.
|
|
6953
|
+
*
|
|
6954
|
+
* @example
|
|
6955
|
+
* ```js
|
|
6956
|
+
* loadImage('https://example.com/example.png').then((img) => {
|
|
6957
|
+
* console.log(img);
|
|
6958
|
+
* }).catch((err) => {
|
|
6959
|
+
* console.log(err);
|
|
6960
|
+
* });
|
|
6961
|
+
* ```
|
|
6962
|
+
*
|
|
6963
|
+
* @param {string} url - The image url.
|
|
6964
|
+
* @returns {Promise} Return the Promise object.
|
|
6965
|
+
* @category Load Resource
|
|
6966
|
+
*/
|
|
6967
|
+
function loadImage(url) {
|
|
6968
|
+
return new Promise(function (resolve, reject) {
|
|
6969
|
+
var img = new Image();
|
|
6970
|
+
img.onload = function () {
|
|
6971
|
+
resolve(img);
|
|
6972
|
+
};
|
|
6973
|
+
img.onerror = function (err) {
|
|
6974
|
+
reject(err);
|
|
6975
|
+
};
|
|
6976
|
+
img.src = url;
|
|
6977
|
+
});
|
|
6978
|
+
}
|
|
6607
6979
|
|
|
6608
|
-
export { addClass, addEvent, addStyle, calLongestCommonSubsequence, calLongestCommonSubstring, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, cutCHSString, debounce, deepCopyObject, doFn, floatFixed, floatToPercent, formatDate, genCustomConsole, genHashCode, generateRndNum, generateUniqueNum, getBrowserInfo, getCookie, getDefineListeners, getDomain, getFileSize, getFriendlyInterval, getHashQueryParam, getLocalStorage, getPerformance, getQueryParam, getSessionStorage, getUrlFileType, getUrlParam, hasClass, inRate, invokeEvent, isJSONString, isJsonString, isNonEmptyArray, isNumber, isSafePWAEnv, isSupportWebp, isValidData, isValidEmail, isValidPhoneNumber, isValidUrl, loadCSS, loadScript, mNow, mTrim, newLine, removeClass, removeEvent, setCookie, setLocalStorage, setSessionStorage, throttle, truncateZHString, updateQueryParam, windowLoaded, zAxiosIsValidRes };
|
|
6980
|
+
export { addClass, addEvent, addStyle, calLongestCommonSubsequence, calLongestCommonSubstring, camelCase2Underscore, camelCaseToKebabCase, cancelBubble, clearHtml, convert10To26, convertCamelToKebab, convertCamelToUnder, cutCHSString, debounce, deepCopyObject, doFn, floatFixed, floatToPercent, formatDate, genCustomConsole, genHashCode, genStyleString, generateRndNum, generateUniqueNum, getBrowserInfo, getCookie, getDefineListeners, getDomain, getFileSize, getFriendlyInterval, getHashQueryParam, getLocalStorage, getPerformance, getQueryParam, getSessionStorage, getUrlFileType, getUrlParam, hasClass, inRate, invokeEvent, isJSONString, isJsonString, isNonEmptyArray, isNumber, isSafePWAEnv, isSupportWebp, isValidData, isValidEmail, isValidPhoneNumber, isValidUrl, loadCSS, loadImage, loadScript, mNow, mTrim, newLine, removeClass, removeEvent, sanitizeInput, setCookie, setImgWidHeiBySrc, setLocalStorage, setSessionStorage, throttle, truncateZHString, updateQueryParam, windowLoaded, zAxiosIsValidRes };
|