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.
Files changed (64) hide show
  1. package/README.md +1 -2
  2. package/es/date/get-year.js +4 -0
  3. package/es/date/index.js +4 -1
  4. package/es/date/set-year.js +4 -0
  5. package/es/date/to-gmt-string.js +4 -0
  6. package/es/escape.js +4 -0
  7. package/es/index.js +7 -0
  8. package/es/regexp/dot-all.js +7 -0
  9. package/es/regexp/index.js +1 -0
  10. package/es/regexp/sticky.js +2 -0
  11. package/es/string/index.js +1 -0
  12. package/es/string/substr.js +4 -0
  13. package/es/string/virtual/index.js +1 -0
  14. package/es/string/virtual/substr.js +4 -0
  15. package/es/unescape.js +4 -0
  16. package/features/date/get-year.js +3 -0
  17. package/features/date/set-year.js +3 -0
  18. package/features/date/to-gmt-string.js +3 -0
  19. package/features/escape.js +3 -0
  20. package/features/index.js +7 -0
  21. package/features/regexp/dot-all.js +3 -0
  22. package/features/string/substr.js +3 -0
  23. package/features/string/virtual/substr.js +3 -0
  24. package/features/unescape.js +3 -0
  25. package/internals/array-sort.js +45 -0
  26. package/internals/engine-ff-version.js +5 -0
  27. package/internals/engine-is-ie-or-edge.js +3 -0
  28. package/internals/engine-webkit-version.js +5 -0
  29. package/internals/fix-regexp-well-known-symbol-logic.js +5 -62
  30. package/internals/internal-metadata.js +1 -1
  31. package/internals/object-prototype-accessors-forced.js +2 -3
  32. package/internals/regexp-exec.js +29 -5
  33. package/internals/regexp-sticky-helpers.js +3 -7
  34. package/internals/regexp-unsupported-dot-all.js +7 -0
  35. package/internals/regexp-unsupported-ncg.js +8 -0
  36. package/internals/shared.js +1 -1
  37. package/modules/es.array.sort.js +73 -4
  38. package/modules/es.date.get-year.js +12 -0
  39. package/modules/es.date.set-year.js +18 -0
  40. package/modules/es.date.to-gmt-string.js +7 -0
  41. package/modules/es.escape.js +35 -0
  42. package/modules/es.promise.js +3 -2
  43. package/modules/es.regexp.constructor.js +125 -24
  44. package/modules/es.regexp.dot-all.js +22 -0
  45. package/modules/es.regexp.flags.js +10 -8
  46. package/modules/es.regexp.sticky.js +1 -1
  47. package/modules/es.string.match.js +5 -5
  48. package/modules/es.string.replace.js +37 -10
  49. package/modules/es.string.search.js +5 -5
  50. package/modules/es.string.split.js +18 -6
  51. package/modules/es.string.substr.js +25 -0
  52. package/modules/es.typed-array.sort.js +77 -3
  53. package/modules/es.unescape.js +39 -0
  54. package/modules/web.url.js +3 -3
  55. package/package.json +2 -2
  56. package/stable/date/get-year.js +3 -0
  57. package/stable/date/set-year.js +3 -0
  58. package/stable/date/to-gmt-string.js +3 -0
  59. package/stable/escape.js +3 -0
  60. package/stable/index.js +7 -0
  61. package/stable/regexp/dot-all.js +3 -0
  62. package/stable/string/substr.js +3 -0
  63. package/stable/string/virtual/substr.js +3 -0
  64. package/stable/unescape.js +3 -0
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # core-js
2
2
 
3
- [![Sponsors on Open Collective](https://opencollective.com/core-js/sponsors/badge.svg)](#sponsors) [![Backers on Open Collective](https://opencollective.com/core-js/backers/badge.svg)](#backers) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/zloirock/core-js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![npm downloads](https://img.shields.io/npm/dm/core-js.svg)](http://npm-stat.com/charts.html?package=core-js&author=&from=2014-11-18) [![tests](https://github.com/zloirock/core-js/workflows/tests/badge.svg)](https://github.com/zloirock/core-js/actions)
4
- [![eslint](https://github.com/zloirock/core-js/workflows/eslint/badge.svg)](https://github.com/zloirock/core-js/actions)
3
+ [![Open Collective](https://opencollective.com/core-js/all/badge.svg?label=open%20collective)](https://opencollective.com/core-js) [![version](https://img.shields.io/npm/v/core-js.svg)](https://www.npmjs.com/package/core-js) [![core-js downloads](https://img.shields.io/npm/dm/core-js.svg?label=npm%20i%20core-js)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=core-js-compat&from=2014-11-18) [![core-js-pure downloads](https://img.shields.io/npm/dm/core-js-pure.svg?label=npm%20i%20core-js-pure)](https://npm-stat.com/charts.html?package=core-js&package=core-js-pure&package=core-js-compat&from=2014-11-18) [![tests](https://github.com/zloirock/core-js/workflows/tests/badge.svg)](https://github.com/zloirock/core-js/actions) [![eslint](https://github.com/zloirock/core-js/workflows/eslint/badge.svg)](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
 
@@ -0,0 +1,4 @@
1
+ require('../../modules/es.date.get-year');
2
+ var entryUnbind = require('../../internals/entry-unbind');
3
+
4
+ module.exports = entryUnbind('Date', 'getYear');
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.to-json');
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');
@@ -0,0 +1,4 @@
1
+ require('../../modules/es.date.set-year');
2
+ var entryUnbind = require('../../internals/entry-unbind');
3
+
4
+ module.exports = entryUnbind('Date', 'setYear');
@@ -0,0 +1,4 @@
1
+ require('../../modules/es.date.to-gmt-string');
2
+ var entryUnbind = require('../../internals/entry-unbind');
3
+
4
+ module.exports = entryUnbind('Date', 'toGMTString');
package/es/escape.js ADDED
@@ -0,0 +1,4 @@
1
+ require('../modules/es.escape');
2
+ var global = require('../internals/global');
3
+
4
+ module.exports = global.escape;
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
 
@@ -0,0 +1,7 @@
1
+ require('../../modules/es.regexp.constructor');
2
+ require('../../modules/es.regexp.dot-all');
3
+ require('../../modules/es.regexp.exec');
4
+
5
+ module.exports = function (it) {
6
+ return it.dotAll;
7
+ };
@@ -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');
@@ -1,3 +1,5 @@
1
+ require('../../modules/es.regexp.constructor');
2
+ require('../../modules/es.regexp.exec');
1
3
  require('../../modules/es.regexp.sticky');
2
4
 
3
5
  module.exports = function (it) {
@@ -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');
@@ -0,0 +1,4 @@
1
+ require('../../modules/es.string.substr');
2
+ var entryUnbind = require('../../internals/entry-unbind');
3
+
4
+ module.exports = entryUnbind('String', 'substr');
@@ -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');
@@ -0,0 +1,4 @@
1
+ require('../../../modules/es.string.substr');
2
+ var entryVirtual = require('../../../internals/entry-virtual');
3
+
4
+ module.exports = entryVirtual('String').substr;
package/es/unescape.js ADDED
@@ -0,0 +1,4 @@
1
+ require('../modules/es.unescape');
2
+ var global = require('../internals/global');
3
+
4
+ module.exports = global.unescape;
@@ -0,0 +1,3 @@
1
+ var parent = require('../../stable/date/get-year');
2
+
3
+ module.exports = parent;
@@ -0,0 +1,3 @@
1
+ var parent = require('../../stable/date/set-year');
2
+
3
+ module.exports = parent;
@@ -0,0 +1,3 @@
1
+ var parent = require('../../stable/date/to-gmt-string');
2
+
3
+ module.exports = parent;
@@ -0,0 +1,3 @@
1
+ var parent = require('../stable/escape');
2
+
3
+ module.exports = parent;
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,3 @@
1
+ var parent = require('../../stable/regexp/dot-all');
2
+
3
+ module.exports = parent;
@@ -0,0 +1,3 @@
1
+ var parent = require('../../stable/string/substr');
2
+
3
+ module.exports = parent;
@@ -0,0 +1,3 @@
1
+ var parent = require('../../../stable/string/virtual/substr');
2
+
3
+ module.exports = parent;
@@ -0,0 +1,3 @@
1
+ var parent = require('../stable/unescape');
2
+
3
+ module.exports = parent;
@@ -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;
@@ -0,0 +1,5 @@
1
+ var userAgent = require('../internals/engine-user-agent');
2
+
3
+ var firefox = userAgent.match(/firefox\/(\d+)/i);
4
+
5
+ module.exports = !!firefox && +firefox[1];
@@ -0,0 +1,3 @@
1
+ var UA = require('../internals/engine-user-agent');
2
+
3
+ module.exports = /MSIE|Trident/.test(UA);
@@ -0,0 +1,5 @@
1
+ var userAgent = require('../internals/engine-user-agent');
2
+
3
+ var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
4
+
5
+ module.exports = !!webkit && +webkit[1];
@@ -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
- var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
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
- (KEY === 'replace' && !(
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, stringMethod);
118
- redefine(RegExpPrototype, SYMBOL, length == 2
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 (sham) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
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' + ++id, // object ID
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 userAgent = require('../internals/engine-user-agent');
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
- var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
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
@@ -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('./regexp-flags');
5
- var stickyHelpers = require('./regexp-sticky-helpers');
6
- var shared = require('./shared');
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 lastIndex, reCopy, match, i;
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
- 'use strict';
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
- // so we use an intermediate function.
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,7 @@
1
+ var fails = require('./fails');
2
+
3
+ module.exports = fails(function () {
4
+ // babel-minify transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
5
+ var re = RegExp('.', (typeof '').charAt(0));
6
+ return !(re.dotAll && re.exec('\n') && re.flags === 's');
7
+ });
@@ -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
+ });
@@ -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.13.1',
7
+ version: '3.15.2',
8
8
  mode: IS_PURE ? 'pure' : 'global',
9
9
  copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
10
10
  });
@@ -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 FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD;
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
- return comparefn === undefined
29
- ? nativeSort.call(toObject(this))
30
- : nativeSort.call(toObject(this), aFunction(comparefn));
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
+ });