core-js 3.35.0 → 3.35.1
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/LICENSE +1 -1
- package/internals/export.js +1 -1
- package/internals/fix-regexp-well-known-symbol-logic.js +5 -6
- package/internals/is-constructor.js +1 -2
- package/internals/make-built-in.js +1 -1
- package/internals/shared.js +3 -3
- package/internals/to-length.js +2 -1
- package/modules/es.string.replace-all.js +2 -8
- package/modules/es.string.split.js +21 -67
- package/package.json +1 -1
package/LICENSE
CHANGED
package/internals/export.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = function (options, source) {
|
|
|
32
32
|
} else if (STATIC) {
|
|
33
33
|
target = global[TARGET] || defineGlobalProperty(TARGET, {});
|
|
34
34
|
} else {
|
|
35
|
-
target =
|
|
35
|
+
target = global[TARGET] && global[TARGET].prototype;
|
|
36
36
|
}
|
|
37
37
|
if (target) for (key in source) {
|
|
38
38
|
sourceProperty = source[key];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// TODO: Remove from `core-js@4` since it's moved to entry points
|
|
3
3
|
require('../modules/es.regexp.exec');
|
|
4
|
-
var
|
|
4
|
+
var call = require('../internals/function-call');
|
|
5
5
|
var defineBuiltIn = require('../internals/define-built-in');
|
|
6
6
|
var regexpExec = require('../internals/regexp-exec');
|
|
7
7
|
var fails = require('../internals/fails');
|
|
@@ -15,7 +15,7 @@ module.exports = function (KEY, exec, FORCED, SHAM) {
|
|
|
15
15
|
var SYMBOL = wellKnownSymbol(KEY);
|
|
16
16
|
|
|
17
17
|
var DELEGATES_TO_SYMBOL = !fails(function () {
|
|
18
|
-
// String methods call symbol-named
|
|
18
|
+
// String methods call symbol-named RegExp methods
|
|
19
19
|
var O = {};
|
|
20
20
|
O[SYMBOL] = function () { return 7; };
|
|
21
21
|
return ''[KEY](O) !== 7;
|
|
@@ -53,18 +53,17 @@ module.exports = function (KEY, exec, FORCED, SHAM) {
|
|
|
53
53
|
!DELEGATES_TO_EXEC ||
|
|
54
54
|
FORCED
|
|
55
55
|
) {
|
|
56
|
-
var
|
|
56
|
+
var nativeRegExpMethod = /./[SYMBOL];
|
|
57
57
|
var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
|
|
58
|
-
var uncurriedNativeMethod = uncurryThis(nativeMethod);
|
|
59
58
|
var $exec = regexp.exec;
|
|
60
59
|
if ($exec === regexpExec || $exec === RegExpPrototype.exec) {
|
|
61
60
|
if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
|
|
62
61
|
// The native String method already delegates to @@method (this
|
|
63
62
|
// polyfilled function), leasing to infinite recursion.
|
|
64
63
|
// We avoid it by directly calling the native @@method method.
|
|
65
|
-
return { done: true, value:
|
|
64
|
+
return { done: true, value: call(nativeRegExpMethod, regexp, str, arg2) };
|
|
66
65
|
}
|
|
67
|
-
return { done: true, value:
|
|
66
|
+
return { done: true, value: call(nativeMethod, str, regexp, arg2) };
|
|
68
67
|
}
|
|
69
68
|
return { done: false };
|
|
70
69
|
});
|
|
@@ -7,7 +7,6 @@ var getBuiltIn = require('../internals/get-built-in');
|
|
|
7
7
|
var inspectSource = require('../internals/inspect-source');
|
|
8
8
|
|
|
9
9
|
var noop = function () { /* empty */ };
|
|
10
|
-
var empty = [];
|
|
11
10
|
var construct = getBuiltIn('Reflect', 'construct');
|
|
12
11
|
var constructorRegExp = /^\s*(?:class|function)\b/;
|
|
13
12
|
var exec = uncurryThis(constructorRegExp.exec);
|
|
@@ -16,7 +15,7 @@ var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
|
|
|
16
15
|
var isConstructorModern = function isConstructor(argument) {
|
|
17
16
|
if (!isCallable(argument)) return false;
|
|
18
17
|
try {
|
|
19
|
-
construct(noop,
|
|
18
|
+
construct(noop, [], argument);
|
|
20
19
|
return true;
|
|
21
20
|
} catch (error) {
|
|
22
21
|
return false;
|
|
@@ -25,7 +25,7 @@ var TEMPLATE = String(String).split('String');
|
|
|
25
25
|
|
|
26
26
|
var makeBuiltIn = module.exports = function (value, name, options) {
|
|
27
27
|
if (stringSlice($String(name), 0, 7) === 'Symbol(') {
|
|
28
|
-
name = '[' + replace($String(name), /^Symbol\(([^)]*)\)
|
|
28
|
+
name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
|
|
29
29
|
}
|
|
30
30
|
if (options && options.getter) name = 'get ' + name;
|
|
31
31
|
if (options && options.setter) name = 'set ' + name;
|
package/internals/shared.js
CHANGED
|
@@ -5,9 +5,9 @@ var store = require('../internals/shared-store');
|
|
|
5
5
|
(module.exports = function (key, value) {
|
|
6
6
|
return store[key] || (store[key] = value !== undefined ? value : {});
|
|
7
7
|
})('versions', []).push({
|
|
8
|
-
version: '3.35.
|
|
8
|
+
version: '3.35.1',
|
|
9
9
|
mode: IS_PURE ? 'pure' : 'global',
|
|
10
|
-
copyright: '© 2014-
|
|
11
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.35.
|
|
10
|
+
copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
|
|
11
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.35.1/LICENSE',
|
|
12
12
|
source: 'https://github.com/zloirock/core-js'
|
|
13
13
|
});
|
package/internals/to-length.js
CHANGED
|
@@ -6,5 +6,6 @@ var min = Math.min;
|
|
|
6
6
|
// `ToLength` abstract operation
|
|
7
7
|
// https://tc39.es/ecma262/#sec-tolength
|
|
8
8
|
module.exports = function (argument) {
|
|
9
|
-
|
|
9
|
+
var len = toIntegerOrInfinity(argument);
|
|
10
|
+
return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
|
|
10
11
|
};
|
|
@@ -20,12 +20,6 @@ var replace = uncurryThis(''.replace);
|
|
|
20
20
|
var stringSlice = uncurryThis(''.slice);
|
|
21
21
|
var max = Math.max;
|
|
22
22
|
|
|
23
|
-
var stringIndexOf = function (string, searchValue, fromIndex) {
|
|
24
|
-
if (fromIndex > string.length) return -1;
|
|
25
|
-
if (searchValue === '') return fromIndex;
|
|
26
|
-
return indexOf(string, searchValue, fromIndex);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
23
|
// `String.prototype.replaceAll` method
|
|
30
24
|
// https://tc39.es/ecma262/#sec-string.prototype.replaceall
|
|
31
25
|
$({ target: 'String', proto: true }, {
|
|
@@ -54,14 +48,14 @@ $({ target: 'String', proto: true }, {
|
|
|
54
48
|
if (!functionalReplace) replaceValue = toString(replaceValue);
|
|
55
49
|
searchLength = searchString.length;
|
|
56
50
|
advanceBy = max(1, searchLength);
|
|
57
|
-
position =
|
|
51
|
+
position = indexOf(string, searchString);
|
|
58
52
|
while (position !== -1) {
|
|
59
53
|
replacement = functionalReplace
|
|
60
54
|
? toString(replaceValue(searchString, position, string))
|
|
61
55
|
: getSubstitution(searchString, string, position, [], undefined, replaceValue);
|
|
62
56
|
result += stringSlice(string, endOfLastMatch, position) + replacement;
|
|
63
57
|
endOfLastMatch = position + searchLength;
|
|
64
|
-
position =
|
|
58
|
+
position = position + advanceBy > string.length ? -1 : indexOf(string, searchString, position + advanceBy);
|
|
65
59
|
}
|
|
66
60
|
if (endOfLastMatch < string.length) {
|
|
67
61
|
result += stringSlice(string, endOfLastMatch);
|
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
var apply = require('../internals/function-apply');
|
|
3
2
|
var call = require('../internals/function-call');
|
|
4
3
|
var uncurryThis = require('../internals/function-uncurry-this');
|
|
5
4
|
var fixRegExpWellKnownSymbolLogic = require('../internals/fix-regexp-well-known-symbol-logic');
|
|
6
5
|
var anObject = require('../internals/an-object');
|
|
7
6
|
var isNullOrUndefined = require('../internals/is-null-or-undefined');
|
|
8
|
-
var isRegExp = require('../internals/is-regexp');
|
|
9
7
|
var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
10
8
|
var speciesConstructor = require('../internals/species-constructor');
|
|
11
9
|
var advanceStringIndex = require('../internals/advance-string-index');
|
|
12
10
|
var toLength = require('../internals/to-length');
|
|
13
11
|
var toString = require('../internals/to-string');
|
|
14
12
|
var getMethod = require('../internals/get-method');
|
|
15
|
-
var
|
|
16
|
-
var callRegExpExec = require('../internals/regexp-exec-abstract');
|
|
17
|
-
var regexpExec = require('../internals/regexp-exec');
|
|
13
|
+
var regExpExec = require('../internals/regexp-exec-abstract');
|
|
18
14
|
var stickyHelpers = require('../internals/regexp-sticky-helpers');
|
|
19
15
|
var fails = require('../internals/fails');
|
|
20
16
|
|
|
21
17
|
var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
|
|
22
18
|
var MAX_UINT32 = 0xFFFFFFFF;
|
|
23
19
|
var min = Math.min;
|
|
24
|
-
var
|
|
25
|
-
var exec = uncurryThis(/./.exec);
|
|
26
|
-
var push = uncurryThis($push);
|
|
20
|
+
var push = uncurryThis([].push);
|
|
27
21
|
var stringSlice = uncurryThis(''.slice);
|
|
28
22
|
|
|
29
23
|
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
|
|
@@ -37,60 +31,20 @@ var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
|
|
|
37
31
|
return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
|
|
38
32
|
});
|
|
39
33
|
|
|
34
|
+
var BUGGY = 'abbc'.split(/(b)*/)[1] === 'c' ||
|
|
35
|
+
// eslint-disable-next-line regexp/no-empty-group -- required for testing
|
|
36
|
+
'test'.split(/(?:)/, -1).length !== 4 ||
|
|
37
|
+
'ab'.split(/(?:ab)*/).length !== 2 ||
|
|
38
|
+
'.'.split(/(.?)(.?)/).length !== 4 ||
|
|
39
|
+
// eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
|
|
40
|
+
'.'.split(/()()/).length > 1 ||
|
|
41
|
+
''.split(/.?/).length;
|
|
42
|
+
|
|
40
43
|
// @@split logic
|
|
41
44
|
fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
|
|
42
|
-
var internalSplit
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// eslint-disable-next-line regexp/no-empty-group -- required for testing
|
|
46
|
-
'test'.split(/(?:)/, -1).length !== 4 ||
|
|
47
|
-
'ab'.split(/(?:ab)*/).length !== 2 ||
|
|
48
|
-
'.'.split(/(.?)(.?)/).length !== 4 ||
|
|
49
|
-
// eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
|
|
50
|
-
'.'.split(/()()/).length > 1 ||
|
|
51
|
-
''.split(/.?/).length
|
|
52
|
-
) {
|
|
53
|
-
// based on es5-shim implementation, need to rework it
|
|
54
|
-
internalSplit = function (separator, limit) {
|
|
55
|
-
var string = toString(requireObjectCoercible(this));
|
|
56
|
-
var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
|
|
57
|
-
if (lim === 0) return [];
|
|
58
|
-
if (separator === undefined) return [string];
|
|
59
|
-
// If `separator` is not a regex, use native split
|
|
60
|
-
if (!isRegExp(separator)) {
|
|
61
|
-
return call(nativeSplit, string, separator, lim);
|
|
62
|
-
}
|
|
63
|
-
var output = [];
|
|
64
|
-
var flags = (separator.ignoreCase ? 'i' : '') +
|
|
65
|
-
(separator.multiline ? 'm' : '') +
|
|
66
|
-
(separator.unicode ? 'u' : '') +
|
|
67
|
-
(separator.sticky ? 'y' : '');
|
|
68
|
-
var lastLastIndex = 0;
|
|
69
|
-
// Make `global` and avoid `lastIndex` issues by working with a copy
|
|
70
|
-
var separatorCopy = new RegExp(separator.source, flags + 'g');
|
|
71
|
-
var match, lastIndex, lastLength;
|
|
72
|
-
while (match = call(regexpExec, separatorCopy, string)) {
|
|
73
|
-
lastIndex = separatorCopy.lastIndex;
|
|
74
|
-
if (lastIndex > lastLastIndex) {
|
|
75
|
-
push(output, stringSlice(string, lastLastIndex, match.index));
|
|
76
|
-
if (match.length > 1 && match.index < string.length) apply($push, output, arraySlice(match, 1));
|
|
77
|
-
lastLength = match[0].length;
|
|
78
|
-
lastLastIndex = lastIndex;
|
|
79
|
-
if (output.length >= lim) break;
|
|
80
|
-
}
|
|
81
|
-
if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
|
|
82
|
-
}
|
|
83
|
-
if (lastLastIndex === string.length) {
|
|
84
|
-
if (lastLength || !exec(separatorCopy, '')) push(output, '');
|
|
85
|
-
} else push(output, stringSlice(string, lastLastIndex));
|
|
86
|
-
return output.length > lim ? arraySlice(output, 0, lim) : output;
|
|
87
|
-
};
|
|
88
|
-
// Chakra, V8
|
|
89
|
-
} else if ('0'.split(undefined, 0).length) {
|
|
90
|
-
internalSplit = function (separator, limit) {
|
|
91
|
-
return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit);
|
|
92
|
-
};
|
|
93
|
-
} else internalSplit = nativeSplit;
|
|
45
|
+
var internalSplit = '0'.split(undefined, 0).length ? function (separator, limit) {
|
|
46
|
+
return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit);
|
|
47
|
+
} : nativeSplit;
|
|
94
48
|
|
|
95
49
|
return [
|
|
96
50
|
// `String.prototype.split` method
|
|
@@ -110,30 +64,30 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
|
|
|
110
64
|
function (string, limit) {
|
|
111
65
|
var rx = anObject(this);
|
|
112
66
|
var S = toString(string);
|
|
113
|
-
var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
|
|
114
67
|
|
|
115
|
-
if (
|
|
68
|
+
if (!BUGGY) {
|
|
69
|
+
var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
|
|
70
|
+
if (res.done) return res.value;
|
|
71
|
+
}
|
|
116
72
|
|
|
117
73
|
var C = speciesConstructor(rx, RegExp);
|
|
118
|
-
|
|
119
74
|
var unicodeMatching = rx.unicode;
|
|
120
75
|
var flags = (rx.ignoreCase ? 'i' : '') +
|
|
121
76
|
(rx.multiline ? 'm' : '') +
|
|
122
77
|
(rx.unicode ? 'u' : '') +
|
|
123
78
|
(UNSUPPORTED_Y ? 'g' : 'y');
|
|
124
|
-
|
|
125
79
|
// ^(? + rx + ) is needed, in combination with some S slicing, to
|
|
126
80
|
// simulate the 'y' flag.
|
|
127
81
|
var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
|
|
128
82
|
var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
|
|
129
83
|
if (lim === 0) return [];
|
|
130
|
-
if (S.length === 0) return
|
|
84
|
+
if (S.length === 0) return regExpExec(splitter, S) === null ? [S] : [];
|
|
131
85
|
var p = 0;
|
|
132
86
|
var q = 0;
|
|
133
87
|
var A = [];
|
|
134
88
|
while (q < S.length) {
|
|
135
89
|
splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
|
|
136
|
-
var z =
|
|
90
|
+
var z = regExpExec(splitter, UNSUPPORTED_Y ? stringSlice(S, q) : S);
|
|
137
91
|
var e;
|
|
138
92
|
if (
|
|
139
93
|
z === null ||
|
|
@@ -154,4 +108,4 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
|
|
|
154
108
|
return A;
|
|
155
109
|
}
|
|
156
110
|
];
|
|
157
|
-
}, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
|
|
111
|
+
}, BUGGY || !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
|