core-js 3.13.1 → 3.15.2
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 +1 -2
- package/es/date/get-year.js +4 -0
- package/es/date/index.js +4 -1
- package/es/date/set-year.js +4 -0
- package/es/date/to-gmt-string.js +4 -0
- package/es/escape.js +4 -0
- package/es/index.js +7 -0
- package/es/regexp/dot-all.js +7 -0
- package/es/regexp/index.js +1 -0
- package/es/regexp/sticky.js +2 -0
- package/es/string/index.js +1 -0
- package/es/string/substr.js +4 -0
- package/es/string/virtual/index.js +1 -0
- package/es/string/virtual/substr.js +4 -0
- package/es/unescape.js +4 -0
- package/features/date/get-year.js +3 -0
- package/features/date/set-year.js +3 -0
- package/features/date/to-gmt-string.js +3 -0
- package/features/escape.js +3 -0
- package/features/index.js +7 -0
- package/features/regexp/dot-all.js +3 -0
- package/features/string/substr.js +3 -0
- package/features/string/virtual/substr.js +3 -0
- package/features/unescape.js +3 -0
- package/internals/array-sort.js +45 -0
- package/internals/engine-ff-version.js +5 -0
- package/internals/engine-is-ie-or-edge.js +3 -0
- package/internals/engine-webkit-version.js +5 -0
- package/internals/fix-regexp-well-known-symbol-logic.js +5 -62
- package/internals/internal-metadata.js +1 -1
- package/internals/object-prototype-accessors-forced.js +2 -3
- package/internals/regexp-exec.js +29 -5
- package/internals/regexp-sticky-helpers.js +3 -7
- package/internals/regexp-unsupported-dot-all.js +7 -0
- package/internals/regexp-unsupported-ncg.js +8 -0
- package/internals/shared.js +1 -1
- package/modules/es.array.sort.js +73 -4
- package/modules/es.date.get-year.js +12 -0
- package/modules/es.date.set-year.js +18 -0
- package/modules/es.date.to-gmt-string.js +7 -0
- package/modules/es.escape.js +35 -0
- package/modules/es.promise.js +3 -2
- package/modules/es.regexp.constructor.js +125 -24
- package/modules/es.regexp.dot-all.js +22 -0
- package/modules/es.regexp.flags.js +10 -8
- package/modules/es.regexp.sticky.js +1 -1
- package/modules/es.string.match.js +5 -5
- package/modules/es.string.replace.js +37 -10
- package/modules/es.string.search.js +5 -5
- package/modules/es.string.split.js +18 -6
- package/modules/es.string.substr.js +25 -0
- package/modules/es.typed-array.sort.js +77 -3
- package/modules/es.unescape.js +39 -0
- package/modules/web.url.js +3 -3
- package/package.json +2 -2
- package/stable/date/get-year.js +3 -0
- package/stable/date/set-year.js +3 -0
- package/stable/date/to-gmt-string.js +3 -0
- package/stable/escape.js +3 -0
- package/stable/index.js +7 -0
- package/stable/regexp/dot-all.js +3 -0
- package/stable/string/substr.js +3 -0
- package/stable/string/virtual/substr.js +3 -0
- package/stable/unescape.js +3 -0
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# core-js
|
|
2
2
|
|
|
3
|
-
[](https://github.com/zloirock/core-js/actions)
|
|
3
|
+
[](https://opencollective.com/core-js) [](https://www.npmjs.com/package/core-js) [](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=core-js-compat&from=2014-11-18) [](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=core-js-compat&from=2014-11-18) [](https://github.com/zloirock/core-js/actions) [](https://github.com/zloirock/core-js/actions)
|
|
5
4
|
|
|
6
5
|
> Modular standard library for JavaScript. Includes polyfills for [ECMAScript up to 2021](https://github.com/zloirock/core-js#ecmascript): [promises](https://github.com/zloirock/core-js#ecmascript-promise), [symbols](https://github.com/zloirock/core-js#ecmascript-symbol), [collections](https://github.com/zloirock/core-js#ecmascript-collections), iterators, [typed arrays](https://github.com/zloirock/core-js#ecmascript-typed-arrays), many other features, [ECMAScript proposals](https://github.com/zloirock/core-js#ecmascript-proposals), [some cross-platform WHATWG / W3C features and proposals](#web-standards) like [`URL`](https://github.com/zloirock/core-js#url-and-urlsearchparams). You can load only required features or use it without global namespace pollution.
|
|
7
6
|
|
package/es/date/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
require('../../modules/es.date.get-year');
|
|
1
2
|
require('../../modules/es.date.now');
|
|
2
|
-
require('../../modules/es.date.
|
|
3
|
+
require('../../modules/es.date.set-year');
|
|
4
|
+
require('../../modules/es.date.to-gmt-string');
|
|
3
5
|
require('../../modules/es.date.to-iso-string');
|
|
6
|
+
require('../../modules/es.date.to-json');
|
|
4
7
|
require('../../modules/es.date.to-string');
|
|
5
8
|
require('../../modules/es.date.to-primitive');
|
|
6
9
|
var path = require('../../internals/path');
|
package/es/escape.js
ADDED
package/es/index.js
CHANGED
|
@@ -47,11 +47,15 @@ require('../modules/es.array-buffer.constructor');
|
|
|
47
47
|
require('../modules/es.array-buffer.is-view');
|
|
48
48
|
require('../modules/es.array-buffer.slice');
|
|
49
49
|
require('../modules/es.data-view');
|
|
50
|
+
require('../modules/es.date.get-year');
|
|
50
51
|
require('../modules/es.date.now');
|
|
52
|
+
require('../modules/es.date.set-year');
|
|
53
|
+
require('../modules/es.date.to-gmt-string');
|
|
51
54
|
require('../modules/es.date.to-iso-string');
|
|
52
55
|
require('../modules/es.date.to-json');
|
|
53
56
|
require('../modules/es.date.to-primitive');
|
|
54
57
|
require('../modules/es.date.to-string');
|
|
58
|
+
require('../modules/es.escape');
|
|
55
59
|
require('../modules/es.function.bind');
|
|
56
60
|
require('../modules/es.function.has-instance');
|
|
57
61
|
require('../modules/es.function.name');
|
|
@@ -135,6 +139,7 @@ require('../modules/es.reflect.set');
|
|
|
135
139
|
require('../modules/es.reflect.set-prototype-of');
|
|
136
140
|
require('../modules/es.reflect.to-string-tag');
|
|
137
141
|
require('../modules/es.regexp.constructor');
|
|
142
|
+
require('../modules/es.regexp.dot-all');
|
|
138
143
|
require('../modules/es.regexp.exec');
|
|
139
144
|
require('../modules/es.regexp.flags');
|
|
140
145
|
require('../modules/es.regexp.sticky');
|
|
@@ -157,6 +162,7 @@ require('../modules/es.string.replace-all');
|
|
|
157
162
|
require('../modules/es.string.search');
|
|
158
163
|
require('../modules/es.string.split');
|
|
159
164
|
require('../modules/es.string.starts-with');
|
|
165
|
+
require('../modules/es.string.substr');
|
|
160
166
|
require('../modules/es.string.trim');
|
|
161
167
|
require('../modules/es.string.trim-end');
|
|
162
168
|
require('../modules/es.string.trim-start');
|
|
@@ -207,6 +213,7 @@ require('../modules/es.typed-array.sort');
|
|
|
207
213
|
require('../modules/es.typed-array.subarray');
|
|
208
214
|
require('../modules/es.typed-array.to-locale-string');
|
|
209
215
|
require('../modules/es.typed-array.to-string');
|
|
216
|
+
require('../modules/es.unescape');
|
|
210
217
|
require('../modules/es.weak-map');
|
|
211
218
|
require('../modules/es.weak-set');
|
|
212
219
|
|
package/es/regexp/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require('../../modules/es.regexp.constructor');
|
|
2
2
|
require('../../modules/es.regexp.to-string');
|
|
3
|
+
require('../../modules/es.regexp.dot-all');
|
|
3
4
|
require('../../modules/es.regexp.exec');
|
|
4
5
|
require('../../modules/es.regexp.flags');
|
|
5
6
|
require('../../modules/es.regexp.sticky');
|
package/es/regexp/sticky.js
CHANGED
package/es/string/index.js
CHANGED
|
@@ -14,6 +14,7 @@ require('../../modules/es.string.replace-all');
|
|
|
14
14
|
require('../../modules/es.string.search');
|
|
15
15
|
require('../../modules/es.string.split');
|
|
16
16
|
require('../../modules/es.string.starts-with');
|
|
17
|
+
require('../../modules/es.string.substr');
|
|
17
18
|
require('../../modules/es.string.trim');
|
|
18
19
|
require('../../modules/es.string.trim-start');
|
|
19
20
|
require('../../modules/es.string.trim-end');
|
|
@@ -11,6 +11,7 @@ require('../../../modules/es.string.replace-all');
|
|
|
11
11
|
require('../../../modules/es.string.search');
|
|
12
12
|
require('../../../modules/es.string.split');
|
|
13
13
|
require('../../../modules/es.string.starts-with');
|
|
14
|
+
require('../../../modules/es.string.substr');
|
|
14
15
|
require('../../../modules/es.string.trim');
|
|
15
16
|
require('../../../modules/es.string.trim-start');
|
|
16
17
|
require('../../../modules/es.string.trim-end');
|
package/es/unescape.js
ADDED
package/features/index.js
CHANGED
|
@@ -47,11 +47,15 @@ require('../modules/es.array-buffer.constructor');
|
|
|
47
47
|
require('../modules/es.array-buffer.is-view');
|
|
48
48
|
require('../modules/es.array-buffer.slice');
|
|
49
49
|
require('../modules/es.data-view');
|
|
50
|
+
require('../modules/es.date.get-year');
|
|
50
51
|
require('../modules/es.date.now');
|
|
52
|
+
require('../modules/es.date.set-year');
|
|
53
|
+
require('../modules/es.date.to-gmt-string');
|
|
51
54
|
require('../modules/es.date.to-iso-string');
|
|
52
55
|
require('../modules/es.date.to-json');
|
|
53
56
|
require('../modules/es.date.to-primitive');
|
|
54
57
|
require('../modules/es.date.to-string');
|
|
58
|
+
require('../modules/es.escape');
|
|
55
59
|
require('../modules/es.function.bind');
|
|
56
60
|
require('../modules/es.function.has-instance');
|
|
57
61
|
require('../modules/es.function.name');
|
|
@@ -135,6 +139,7 @@ require('../modules/es.reflect.set');
|
|
|
135
139
|
require('../modules/es.reflect.set-prototype-of');
|
|
136
140
|
require('../modules/es.reflect.to-string-tag');
|
|
137
141
|
require('../modules/es.regexp.constructor');
|
|
142
|
+
require('../modules/es.regexp.dot-all');
|
|
138
143
|
require('../modules/es.regexp.exec');
|
|
139
144
|
require('../modules/es.regexp.flags');
|
|
140
145
|
require('../modules/es.regexp.sticky');
|
|
@@ -157,6 +162,7 @@ require('../modules/es.string.replace-all');
|
|
|
157
162
|
require('../modules/es.string.search');
|
|
158
163
|
require('../modules/es.string.split');
|
|
159
164
|
require('../modules/es.string.starts-with');
|
|
165
|
+
require('../modules/es.string.substr');
|
|
160
166
|
require('../modules/es.string.trim');
|
|
161
167
|
require('../modules/es.string.trim-end');
|
|
162
168
|
require('../modules/es.string.trim-start');
|
|
@@ -207,6 +213,7 @@ require('../modules/es.typed-array.sort');
|
|
|
207
213
|
require('../modules/es.typed-array.subarray');
|
|
208
214
|
require('../modules/es.typed-array.to-locale-string');
|
|
209
215
|
require('../modules/es.typed-array.to-string');
|
|
216
|
+
require('../modules/es.unescape');
|
|
210
217
|
require('../modules/es.weak-map');
|
|
211
218
|
require('../modules/es.weak-set');
|
|
212
219
|
require('../modules/esnext.aggregate-error');
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// TODO: use something more complex like timsort?
|
|
2
|
+
var floor = Math.floor;
|
|
3
|
+
|
|
4
|
+
var mergeSort = function (array, comparefn) {
|
|
5
|
+
var length = array.length;
|
|
6
|
+
var middle = floor(length / 2);
|
|
7
|
+
return length < 8 ? insertionSort(array, comparefn) : merge(
|
|
8
|
+
mergeSort(array.slice(0, middle), comparefn),
|
|
9
|
+
mergeSort(array.slice(middle), comparefn),
|
|
10
|
+
comparefn
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
var insertionSort = function (array, comparefn) {
|
|
15
|
+
var length = array.length;
|
|
16
|
+
var i = 1;
|
|
17
|
+
var element, j;
|
|
18
|
+
|
|
19
|
+
while (i < length) {
|
|
20
|
+
j = i;
|
|
21
|
+
element = array[i];
|
|
22
|
+
while (j && comparefn(array[j - 1], element) > 0) {
|
|
23
|
+
array[j] = array[--j];
|
|
24
|
+
}
|
|
25
|
+
if (j !== i++) array[j] = element;
|
|
26
|
+
} return array;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var merge = function (left, right, comparefn) {
|
|
30
|
+
var llength = left.length;
|
|
31
|
+
var rlength = right.length;
|
|
32
|
+
var lindex = 0;
|
|
33
|
+
var rindex = 0;
|
|
34
|
+
var result = [];
|
|
35
|
+
|
|
36
|
+
while (lindex < llength || rindex < rlength) {
|
|
37
|
+
if (lindex < llength && rindex < rlength) {
|
|
38
|
+
result.push(comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]);
|
|
39
|
+
} else {
|
|
40
|
+
result.push(lindex < llength ? left[lindex++] : right[rindex++]);
|
|
41
|
+
}
|
|
42
|
+
} return result;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = mergeSort;
|
|
@@ -10,47 +10,7 @@ var createNonEnumerableProperty = require('../internals/create-non-enumerable-pr
|
|
|
10
10
|
var SPECIES = wellKnownSymbol('species');
|
|
11
11
|
var RegExpPrototype = RegExp.prototype;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
// #replace needs built-in support for named groups.
|
|
15
|
-
// #match works fine because it just return the exec results, even if it has
|
|
16
|
-
// a "grops" property.
|
|
17
|
-
var re = /./;
|
|
18
|
-
re.exec = function () {
|
|
19
|
-
var result = [];
|
|
20
|
-
result.groups = { a: '7' };
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
return ''.replace(re, '$<a>') !== '7';
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// IE <= 11 replaces $0 with the whole match, as if it was $&
|
|
27
|
-
// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0
|
|
28
|
-
var REPLACE_KEEPS_$0 = (function () {
|
|
29
|
-
// eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing
|
|
30
|
-
return 'a'.replace(/./, '$0') === '$0';
|
|
31
|
-
})();
|
|
32
|
-
|
|
33
|
-
var REPLACE = wellKnownSymbol('replace');
|
|
34
|
-
// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string
|
|
35
|
-
var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () {
|
|
36
|
-
if (/./[REPLACE]) {
|
|
37
|
-
return /./[REPLACE]('a', '$0') === '';
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
})();
|
|
41
|
-
|
|
42
|
-
// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
|
|
43
|
-
// Weex JS has frozen built-in prototypes, so use try / catch wrapper
|
|
44
|
-
var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
|
|
45
|
-
// eslint-disable-next-line regexp/no-empty-group -- required for testing
|
|
46
|
-
var re = /(?:)/;
|
|
47
|
-
var originalExec = re.exec;
|
|
48
|
-
re.exec = function () { return originalExec.apply(this, arguments); };
|
|
49
|
-
var result = 'ab'.split(re);
|
|
50
|
-
return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
module.exports = function (KEY, length, exec, sham) {
|
|
13
|
+
module.exports = function (KEY, exec, FORCED, SHAM) {
|
|
54
14
|
var SYMBOL = wellKnownSymbol(KEY);
|
|
55
15
|
|
|
56
16
|
var DELEGATES_TO_SYMBOL = !fails(function () {
|
|
@@ -87,12 +47,7 @@ module.exports = function (KEY, length, exec, sham) {
|
|
|
87
47
|
if (
|
|
88
48
|
!DELEGATES_TO_SYMBOL ||
|
|
89
49
|
!DELEGATES_TO_EXEC ||
|
|
90
|
-
|
|
91
|
-
REPLACE_SUPPORTS_NAMED_GROUPS &&
|
|
92
|
-
REPLACE_KEEPS_$0 &&
|
|
93
|
-
!REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
|
|
94
|
-
)) ||
|
|
95
|
-
(KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
|
|
50
|
+
FORCED
|
|
96
51
|
) {
|
|
97
52
|
var nativeRegExpMethod = /./[SYMBOL];
|
|
98
53
|
var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
|
|
@@ -107,23 +62,11 @@ module.exports = function (KEY, length, exec, sham) {
|
|
|
107
62
|
return { done: true, value: nativeMethod.call(str, regexp, arg2) };
|
|
108
63
|
}
|
|
109
64
|
return { done: false };
|
|
110
|
-
}, {
|
|
111
|
-
REPLACE_KEEPS_$0: REPLACE_KEEPS_$0,
|
|
112
|
-
REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE: REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE
|
|
113
65
|
});
|
|
114
|
-
var stringMethod = methods[0];
|
|
115
|
-
var regexMethod = methods[1];
|
|
116
66
|
|
|
117
|
-
redefine(String.prototype, KEY,
|
|
118
|
-
redefine(RegExpPrototype, SYMBOL,
|
|
119
|
-
// 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
|
|
120
|
-
// 21.2.5.11 RegExp.prototype[@@split](string, limit)
|
|
121
|
-
? function (string, arg) { return regexMethod.call(string, this, arg); }
|
|
122
|
-
// 21.2.5.6 RegExp.prototype[@@match](string)
|
|
123
|
-
// 21.2.5.9 RegExp.prototype[@@search](string)
|
|
124
|
-
: function (string) { return regexMethod.call(string, this); }
|
|
125
|
-
);
|
|
67
|
+
redefine(String.prototype, KEY, methods[0]);
|
|
68
|
+
redefine(RegExpPrototype, SYMBOL, methods[1]);
|
|
126
69
|
}
|
|
127
70
|
|
|
128
|
-
if (
|
|
71
|
+
if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
|
|
129
72
|
};
|
|
@@ -15,7 +15,7 @@ var isExtensible = Object.isExtensible || function () {
|
|
|
15
15
|
|
|
16
16
|
var setMetadata = function (it) {
|
|
17
17
|
defineProperty(it, METADATA, { value: {
|
|
18
|
-
objectID: 'O' +
|
|
18
|
+
objectID: 'O' + id++, // object ID
|
|
19
19
|
weakData: {} // weak collections IDs
|
|
20
20
|
} });
|
|
21
21
|
};
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
var IS_PURE = require('../internals/is-pure');
|
|
3
3
|
var global = require('../internals/global');
|
|
4
4
|
var fails = require('../internals/fails');
|
|
5
|
-
var
|
|
5
|
+
var WEBKIT = require('../internals/engine-webkit-version');
|
|
6
6
|
|
|
7
7
|
// Forced replacement object prototype accessors methods
|
|
8
8
|
module.exports = IS_PURE || !fails(function () {
|
|
9
9
|
// This feature detection crashes old WebKit
|
|
10
10
|
// https://github.com/zloirock/core-js/issues/232
|
|
11
|
-
|
|
12
|
-
if (webkit && +webkit[1] < 535) return;
|
|
11
|
+
if (WEBKIT && WEBKIT < 535) return;
|
|
13
12
|
var key = Math.random();
|
|
14
13
|
// In FF throws only define methods
|
|
15
14
|
// eslint-disable-next-line no-undef, no-useless-call -- required for testing
|
package/internals/regexp-exec.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* eslint-disable regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
|
|
3
3
|
/* eslint-disable regexp/no-useless-quantifier -- testing */
|
|
4
|
-
var regexpFlags = require('
|
|
5
|
-
var stickyHelpers = require('
|
|
6
|
-
var shared = require('
|
|
4
|
+
var regexpFlags = require('../internals/regexp-flags');
|
|
5
|
+
var stickyHelpers = require('../internals/regexp-sticky-helpers');
|
|
6
|
+
var shared = require('../internals/shared');
|
|
7
|
+
var create = require('../internals/object-create');
|
|
8
|
+
var getInternalState = require('../internals/internal-state').get;
|
|
9
|
+
var UNSUPPORTED_DOT_ALL = require('../internals/regexp-unsupported-dot-all');
|
|
10
|
+
var UNSUPPORTED_NCG = require('../internals/regexp-unsupported-ncg');
|
|
7
11
|
|
|
8
12
|
var nativeExec = RegExp.prototype.exec;
|
|
9
13
|
var nativeReplace = shared('native-string-replace', String.prototype.replace);
|
|
@@ -23,12 +27,24 @@ var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;
|
|
|
23
27
|
// nonparticipating capturing group, copied from es5-shim's String#split patch.
|
|
24
28
|
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
|
|
25
29
|
|
|
26
|
-
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;
|
|
30
|
+
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
|
|
27
31
|
|
|
28
32
|
if (PATCH) {
|
|
33
|
+
// eslint-disable-next-line max-statements -- TODO
|
|
29
34
|
patchedExec = function exec(str) {
|
|
30
35
|
var re = this;
|
|
31
|
-
var
|
|
36
|
+
var state = getInternalState(re);
|
|
37
|
+
var raw = state.raw;
|
|
38
|
+
var result, reCopy, lastIndex, match, i, object, group;
|
|
39
|
+
|
|
40
|
+
if (raw) {
|
|
41
|
+
raw.lastIndex = re.lastIndex;
|
|
42
|
+
result = patchedExec.call(raw, str);
|
|
43
|
+
re.lastIndex = raw.lastIndex;
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var groups = state.groups;
|
|
32
48
|
var sticky = UNSUPPORTED_Y && re.sticky;
|
|
33
49
|
var flags = regexpFlags.call(re);
|
|
34
50
|
var source = re.source;
|
|
@@ -80,6 +96,14 @@ if (PATCH) {
|
|
|
80
96
|
});
|
|
81
97
|
}
|
|
82
98
|
|
|
99
|
+
if (match && groups) {
|
|
100
|
+
match.groups = object = create(null);
|
|
101
|
+
for (i = 0; i < groups.length; i++) {
|
|
102
|
+
group = groups[i];
|
|
103
|
+
object[group[0]] = match[group[1]];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
83
107
|
return match;
|
|
84
108
|
};
|
|
85
109
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var fails = require('./fails');
|
|
1
|
+
var fails = require('../internals/fails');
|
|
4
2
|
|
|
5
3
|
// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,
|
|
6
|
-
|
|
7
|
-
function RE(s, f) {
|
|
4
|
+
var RE = function (s, f) {
|
|
8
5
|
return RegExp(s, f);
|
|
9
|
-
}
|
|
6
|
+
};
|
|
10
7
|
|
|
11
8
|
exports.UNSUPPORTED_Y = fails(function () {
|
|
12
|
-
// babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
|
|
13
9
|
var re = RE('a', 'y');
|
|
14
10
|
re.lastIndex = 2;
|
|
15
11
|
return re.exec('abcd') != null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var fails = require('./fails');
|
|
2
|
+
|
|
3
|
+
module.exports = fails(function () {
|
|
4
|
+
// babel-minify transpiles RegExp('.', 'g') -> /./g and it causes SyntaxError
|
|
5
|
+
var re = RegExp('(?<a>b)', (typeof '').charAt(5));
|
|
6
|
+
return re.exec('b').groups.a !== 'b' ||
|
|
7
|
+
'b'.replace(re, '$<a>c') !== 'bc';
|
|
8
|
+
});
|
package/internals/shared.js
CHANGED
|
@@ -4,7 +4,7 @@ var store = require('../internals/shared-store');
|
|
|
4
4
|
(module.exports = function (key, value) {
|
|
5
5
|
return store[key] || (store[key] = value !== undefined ? value : {});
|
|
6
6
|
})('versions', []).push({
|
|
7
|
-
version: '3.
|
|
7
|
+
version: '3.15.2',
|
|
8
8
|
mode: IS_PURE ? 'pure' : 'global',
|
|
9
9
|
copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
|
|
10
10
|
});
|
package/modules/es.array.sort.js
CHANGED
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
var $ = require('../internals/export');
|
|
3
3
|
var aFunction = require('../internals/a-function');
|
|
4
4
|
var toObject = require('../internals/to-object');
|
|
5
|
+
var toLength = require('../internals/to-length');
|
|
5
6
|
var fails = require('../internals/fails');
|
|
7
|
+
var internalSort = require('../internals/array-sort');
|
|
6
8
|
var arrayMethodIsStrict = require('../internals/array-method-is-strict');
|
|
9
|
+
var FF = require('../internals/engine-ff-version');
|
|
10
|
+
var IE_OR_EDGE = require('../internals/engine-is-ie-or-edge');
|
|
11
|
+
var V8 = require('../internals/engine-v8-version');
|
|
12
|
+
var WEBKIT = require('../internals/engine-webkit-version');
|
|
7
13
|
|
|
8
14
|
var test = [];
|
|
9
15
|
var nativeSort = test.sort;
|
|
@@ -19,14 +25,77 @@ var FAILS_ON_NULL = fails(function () {
|
|
|
19
25
|
// Old WebKit
|
|
20
26
|
var STRICT_METHOD = arrayMethodIsStrict('sort');
|
|
21
27
|
|
|
22
|
-
var
|
|
28
|
+
var STABLE_SORT = !fails(function () {
|
|
29
|
+
// feature detection can be too slow, so check engines versions
|
|
30
|
+
if (V8) return V8 < 70;
|
|
31
|
+
if (FF && FF > 3) return;
|
|
32
|
+
if (IE_OR_EDGE) return true;
|
|
33
|
+
if (WEBKIT) return WEBKIT < 603;
|
|
34
|
+
|
|
35
|
+
var result = '';
|
|
36
|
+
var code, chr, value, index;
|
|
37
|
+
|
|
38
|
+
// generate an array with more 512 elements (Chakra and old V8 fails only in this case)
|
|
39
|
+
for (code = 65; code < 76; code++) {
|
|
40
|
+
chr = String.fromCharCode(code);
|
|
41
|
+
|
|
42
|
+
switch (code) {
|
|
43
|
+
case 66: case 69: case 70: case 72: value = 3; break;
|
|
44
|
+
case 68: case 71: value = 4; break;
|
|
45
|
+
default: value = 2;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
for (index = 0; index < 47; index++) {
|
|
49
|
+
test.push({ k: chr + index, v: value });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
test.sort(function (a, b) { return b.v - a.v; });
|
|
54
|
+
|
|
55
|
+
for (index = 0; index < test.length; index++) {
|
|
56
|
+
chr = test[index].k.charAt(0);
|
|
57
|
+
if (result.charAt(result.length - 1) !== chr) result += chr;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return result !== 'DGBEFHACIJK';
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
|
|
64
|
+
|
|
65
|
+
var getSortCompare = function (comparefn) {
|
|
66
|
+
return function (x, y) {
|
|
67
|
+
if (y === undefined) return -1;
|
|
68
|
+
if (x === undefined) return 1;
|
|
69
|
+
if (comparefn !== undefined) return +comparefn(x, y) || 0;
|
|
70
|
+
return String(x) > String(y) ? 1 : -1;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
23
73
|
|
|
24
74
|
// `Array.prototype.sort` method
|
|
25
75
|
// https://tc39.es/ecma262/#sec-array.prototype.sort
|
|
26
76
|
$({ target: 'Array', proto: true, forced: FORCED }, {
|
|
27
77
|
sort: function sort(comparefn) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
78
|
+
if (comparefn !== undefined) aFunction(comparefn);
|
|
79
|
+
|
|
80
|
+
var array = toObject(this);
|
|
81
|
+
|
|
82
|
+
if (STABLE_SORT) return comparefn === undefined ? nativeSort.call(array) : nativeSort.call(array, comparefn);
|
|
83
|
+
|
|
84
|
+
var items = [];
|
|
85
|
+
var arrayLength = toLength(array.length);
|
|
86
|
+
var itemsLength, index;
|
|
87
|
+
|
|
88
|
+
for (index = 0; index < arrayLength; index++) {
|
|
89
|
+
if (index in array) items.push(array[index]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
items = internalSort(items, getSortCompare(comparefn));
|
|
93
|
+
itemsLength = items.length;
|
|
94
|
+
index = 0;
|
|
95
|
+
|
|
96
|
+
while (index < itemsLength) array[index] = items[index++];
|
|
97
|
+
while (index < arrayLength) delete array[index++];
|
|
98
|
+
|
|
99
|
+
return array;
|
|
31
100
|
}
|
|
32
101
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var $ = require('../internals/export');
|
|
3
|
+
|
|
4
|
+
var getFullYear = Date.prototype.getFullYear;
|
|
5
|
+
|
|
6
|
+
// `Date.prototype.getYear` method
|
|
7
|
+
// https://tc39.es/ecma262/#sec-date.prototype.getyear
|
|
8
|
+
$({ target: 'Date', proto: true }, {
|
|
9
|
+
getYear: function getYear() {
|
|
10
|
+
return getFullYear.call(this) - 1900;
|
|
11
|
+
}
|
|
12
|
+
});
|