core-js 3.49.0 → 3.51.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.
Files changed (119) hide show
  1. package/actual/iterator/chunks.js +5 -0
  2. package/actual/iterator/concat.js +4 -0
  3. package/actual/iterator/from.js +4 -0
  4. package/actual/iterator/includes.js +5 -0
  5. package/actual/iterator/index.js +4 -1
  6. package/actual/iterator/join.js +5 -0
  7. package/actual/iterator/windows.js +5 -0
  8. package/actual/iterator/zip-keyed.js +6 -21
  9. package/actual/iterator/zip.js +6 -19
  10. package/actual/promise/all-keyed.js +16 -0
  11. package/actual/promise/all-settled-keyed.js +16 -0
  12. package/actual/promise/index.js +4 -0
  13. package/es/index.js +6 -0
  14. package/es/iterator/chunks.js +8 -0
  15. package/es/iterator/concat.js +4 -0
  16. package/es/iterator/from.js +4 -0
  17. package/es/iterator/includes.js +8 -0
  18. package/es/iterator/index.js +8 -0
  19. package/es/iterator/join.js +8 -0
  20. package/es/iterator/windows.js +8 -0
  21. package/es/iterator/zip-keyed.js +28 -0
  22. package/es/iterator/zip.js +26 -0
  23. package/features/iterator/includes.js +2 -0
  24. package/features/iterator/join.js +2 -0
  25. package/features/promise/all-keyed.js +2 -0
  26. package/features/promise/all-settled-keyed.js +2 -0
  27. package/full/index.js +10 -0
  28. package/full/iterator/chunks.js +2 -6
  29. package/full/iterator/concat.js +0 -2
  30. package/full/iterator/from.js +0 -2
  31. package/full/iterator/includes.js +4 -0
  32. package/full/iterator/index.js +0 -2
  33. package/full/iterator/join.js +4 -0
  34. package/full/iterator/range.js +7 -1
  35. package/full/iterator/windows.js +2 -6
  36. package/full/iterator/zip-keyed.js +0 -2
  37. package/full/iterator/zip.js +0 -2
  38. package/full/promise/all-keyed.js +4 -0
  39. package/full/promise/all-settled-keyed.js +4 -0
  40. package/internals/add-disposable-resource.js +1 -1
  41. package/internals/array-fill.js +2 -1
  42. package/internals/array-from-async.js +2 -2
  43. package/internals/array-from.js +8 -2
  44. package/internals/async-iterator-create-proxy.js +14 -2
  45. package/internals/error-stack-clear.js +1 -1
  46. package/internals/get-async-iterator-flattenable.js +1 -1
  47. package/internals/get-async-iterator.js +1 -1
  48. package/internals/get-internal-iterator.js +1 -0
  49. package/internals/get-iterator-flattenable.js +1 -1
  50. package/internals/get-iterator-internal.js +14 -0
  51. package/internals/get-iterator-method-internal.js +14 -0
  52. package/internals/get-iterator-method.js +4 -7
  53. package/internals/get-iterator-record.js +1 -1
  54. package/internals/get-iterator.js +4 -5
  55. package/internals/is-iterable.js +4 -10
  56. package/internals/iterate.js +2 -2
  57. package/internals/iterator-chunk-size-validation.js +17 -0
  58. package/internals/iterator-cleanup-state.js +6 -0
  59. package/internals/iterator-create-proxy.js +10 -4
  60. package/internals/iterator-window.js +2 -4
  61. package/internals/iterators.js +1 -1
  62. package/internals/math-log1p.js +3 -1
  63. package/internals/shared-store.js +2 -2
  64. package/internals/shared.js +3 -1
  65. package/internals/typed-array-from.js +2 -2
  66. package/internals/uint8-from-base64.js +4 -2
  67. package/internals/uint8-from-hex.js +1 -1
  68. package/internals/url-percent-coding.js +171 -0
  69. package/modules/es.date.to-json.js +1 -1
  70. package/modules/es.escape.js +10 -8
  71. package/modules/es.iterator.chunks.js +42 -0
  72. package/modules/es.iterator.concat.js +1 -1
  73. package/modules/es.iterator.drop.js +16 -1
  74. package/modules/es.iterator.flat-map.js +12 -14
  75. package/modules/es.iterator.includes.js +44 -0
  76. package/modules/es.iterator.join.js +31 -0
  77. package/modules/es.iterator.take.js +16 -1
  78. package/modules/es.iterator.windows.js +12 -0
  79. package/modules/es.iterator.zip-keyed.js +70 -0
  80. package/modules/es.iterator.zip.js +92 -0
  81. package/modules/es.json.parse.js +1 -1
  82. package/modules/es.json.stringify.js +150 -34
  83. package/modules/es.map.group-by.js +2 -0
  84. package/modules/es.math.asinh.js +7 -3
  85. package/modules/es.math.cbrt.js +9 -2
  86. package/modules/es.math.sum-precise.js +27 -1
  87. package/modules/es.object.group-by.js +2 -0
  88. package/modules/es.object.proto.js +2 -1
  89. package/modules/es.promise.try.js +16 -8
  90. package/modules/es.regexp.escape.js +2 -1
  91. package/modules/es.string.match-all.js +3 -4
  92. package/modules/es.string.match.js +3 -1
  93. package/modules/es.string.search.js +3 -1
  94. package/modules/es.uint8-array.to-base64.js +22 -5
  95. package/modules/esnext.iterator.chunks.js +2 -43
  96. package/modules/esnext.iterator.includes.js +3 -0
  97. package/modules/esnext.iterator.join.js +3 -0
  98. package/modules/esnext.iterator.windows.js +2 -10
  99. package/modules/esnext.iterator.zip-keyed.js +2 -71
  100. package/modules/esnext.iterator.zip.js +2 -91
  101. package/modules/esnext.observable.from.js +2 -2
  102. package/modules/esnext.promise.all-keyed.js +57 -0
  103. package/modules/esnext.promise.all-settled-keyed.js +62 -0
  104. package/modules/web.url-search-params.constructor.js +11 -143
  105. package/modules/web.url.constructor.js +103 -17
  106. package/modules/web.url.to-json.js +4 -1
  107. package/package.json +4 -1
  108. package/proposals/await-dictionary.js +4 -0
  109. package/proposals/iterator-includes.js +3 -0
  110. package/proposals/iterator-join.js +3 -0
  111. package/stable/index.js +6 -0
  112. package/stable/iterator/chunks.js +4 -0
  113. package/stable/iterator/includes.js +4 -0
  114. package/stable/iterator/join.js +4 -0
  115. package/stable/iterator/windows.js +4 -0
  116. package/stable/iterator/zip-keyed.js +5 -0
  117. package/stable/iterator/zip.js +5 -0
  118. package/stage/3.js +1 -0
  119. package/stage/4.js +3 -0
@@ -1,38 +1,54 @@
1
1
  'use strict';
2
2
  var $ = require('../internals/export');
3
3
  var getBuiltIn = require('../internals/get-built-in');
4
- var apply = require('../internals/function-apply');
5
4
  var call = require('../internals/function-call');
6
5
  var uncurryThis = require('../internals/function-uncurry-this');
7
6
  var fails = require('../internals/fails');
8
7
  var isArray = require('../internals/is-array');
9
8
  var isCallable = require('../internals/is-callable');
9
+ var isObject = require('../internals/is-object');
10
+ var create = require('../internals/object-create');
10
11
  var isRawJSON = require('../internals/is-raw-json');
11
12
  var isSymbol = require('../internals/is-symbol');
12
13
  var classof = require('../internals/classof-raw');
14
+ var thisNumberValue = require('../internals/this-number-value');
15
+ var includes = require('../internals/array-includes').includes;
16
+ var hasOwn = require('../internals/has-own-property');
13
17
  var toString = require('../internals/to-string');
14
- var arraySlice = require('../internals/array-slice');
15
18
  var parseJSONString = require('../internals/parse-json-string');
16
19
  var uid = require('../internals/uid');
17
20
  var NATIVE_SYMBOL = require('../internals/symbol-constructor-detection');
18
21
  var NATIVE_RAW_JSON = require('../internals/native-raw-json');
19
22
 
20
23
  var $String = String;
24
+ var $TypeError = TypeError;
21
25
  var $stringify = getBuiltIn('JSON', 'stringify');
26
+ var $BigInt = getBuiltIn('BigInt');
27
+ var stringValueOf = uncurryThis(''.valueOf);
28
+ var booleanValueOf = uncurryThis(true.valueOf);
29
+ var bigIntValueOf = $BigInt && uncurryThis($BigInt.prototype.valueOf);
22
30
  var exec = uncurryThis(/./.exec);
23
31
  var charAt = uncurryThis(''.charAt);
24
32
  var charCodeAt = uncurryThis(''.charCodeAt);
25
33
  var replace = uncurryThis(''.replace);
26
34
  var slice = uncurryThis(''.slice);
27
35
  var push = uncurryThis([].push);
36
+ var pop = uncurryThis([].pop);
28
37
  var numberToString = uncurryThis(1.1.toString);
29
38
 
30
39
  var surrogates = /[\uD800-\uDFFF]/g;
31
40
  var leadingSurrogates = /^[\uD800-\uDBFF]$/;
32
41
  var trailingSurrogates = /^[\uDC00-\uDFFF]$/;
42
+ var digits = /^\d+$/;
33
43
 
34
- var MARK = uid();
35
- var MARK_LENGTH = MARK.length;
44
+ // a placeholder of a raw JSON value
45
+ var RAW_MARK = uid();
46
+ // a prefix of keys of a reordered object, see `createOrderedObject`
47
+ var KEY_MARK = uid();
48
+ // the last key of a reordered object, marks the end of its serialization
49
+ var END_MARK = uid();
50
+ var RAW_MARK_LENGTH = RAW_MARK.length;
51
+ var KEY_MARK_LENGTH = KEY_MARK.length;
36
52
 
37
53
  var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () {
38
54
  var symbol = getBuiltIn('Symbol')('stringify detection');
@@ -50,16 +66,13 @@ var ILL_FORMED_UNICODE = fails(function () {
50
66
  || $stringify('\uDEAD') !== '"\\udead"';
51
67
  });
52
68
 
53
- var stringifyWithProperSymbolsConversion = WRONG_SYMBOLS_CONVERSION ? function (it, replacer) {
54
- var args = arraySlice(arguments);
55
- var $replacer = getReplacerFunction(replacer);
56
- if (!isCallable($replacer) && (it === undefined || isSymbol(it))) return; // IE8 returns string on undefined
57
- args[1] = function (key, value) {
58
- // some old implementations (like WebKit) could pass numbers as keys
59
- if (isCallable($replacer)) value = call($replacer, this, $String(key), value);
60
- if (!isSymbol(value)) return value;
61
- };
62
- return apply($stringify, null, args);
69
+ var isRawJSONValue = NATIVE_RAW_JSON ? getBuiltIn('JSON', 'isRawJSON') : isRawJSON;
70
+
71
+ var stringifyWithProperSymbolsConversion = WRONG_SYMBOLS_CONVERSION ? function (it, replacer, space) {
72
+ return $stringify(it, function (key, value) {
73
+ var replaced = call(replacer, this, key, value);
74
+ if (!isSymbol(replaced)) return replaced;
75
+ }, space);
63
76
  } : $stringify;
64
77
 
65
78
  var fixIllFormedJSON = function (match, offset, string) {
@@ -73,47 +86,150 @@ var fixIllFormedJSON = function (match, offset, string) {
73
86
  } return match;
74
87
  };
75
88
 
76
- var getReplacerFunction = function (replacer) {
77
- if (isCallable(replacer)) return replacer;
89
+ // `PropertyList` of `JSON.stringify`
90
+ // https://tc39.es/ecma262/#sec-json.stringify
91
+ var getPropertyList = function (replacer) {
78
92
  if (!isArray(replacer)) return;
79
93
  var rawLength = replacer.length;
80
- var keys = [];
94
+ var propertyList = [];
95
+ // a null prototype object is used as a set of already added keys to keep the deduplication linear
96
+ var addedKeys = create(null);
81
97
  for (var i = 0; i < rawLength; i++) {
82
98
  var element = replacer[i];
83
- if (typeof element == 'string') push(keys, element);
84
- else if (typeof element == 'number' || classof(element) === 'Number' || classof(element) === 'String') push(keys, toString(element));
99
+ var key;
100
+ if (typeof element == 'string') key = element;
101
+ else if (typeof element == 'number' || classof(element) === 'Number' || classof(element) === 'String') key = toString(element);
102
+ else continue;
103
+ if (!hasOwn(addedKeys, key)) {
104
+ addedKeys[key] = true;
105
+ push(propertyList, key);
106
+ }
85
107
  }
86
- var keysLength = keys.length;
87
- var root = true;
88
- return function (key, value) {
89
- if (root) {
90
- root = false;
91
- return value;
108
+ return propertyList;
109
+ };
110
+
111
+ // values with such an internal slot are unwrapped by `SerializeJSONProperty` instead of being serialized as objects
112
+ var hasInternalSlot = function (valueOf, it) {
113
+ try {
114
+ valueOf(it);
115
+ return true;
116
+ } catch (error) {
117
+ return false;
118
+ }
119
+ };
120
+
121
+ // the slot check is expensive, so it's performed only for the kind reported by the value itself -
122
+ // a value lying about its kind via `Symbol.toStringTag` is serialized as an ordinary object
123
+ var isBoxedPrimitive = function (it) {
124
+ var kind = classof(it);
125
+ return (kind === 'Number' && hasInternalSlot(thisNumberValue, it))
126
+ || (kind === 'String' && hasInternalSlot(stringValueOf, it))
127
+ || (kind === 'Boolean' && hasInternalSlot(booleanValueOf, it))
128
+ || (!!bigIntValueOf && kind === 'BigInt' && hasInternalSlot(bigIntValueOf, it));
129
+ };
130
+
131
+ // only objects serialized by `SerializeJSONObject` are affected by the property list
132
+ var isSerializedAsObject = function (it) {
133
+ if (!isObject(it) || isCallable(it) || isArray(it)) return false;
134
+ try {
135
+ return !isBoxedPrimitive(it);
136
+ // `classof` reads `Symbol.toStringTag`, so a proxy could throw - it has no internal slots anyway
137
+ } catch (error) {
138
+ return true;
139
+ }
140
+ };
141
+
142
+ // the engine unwraps it in the same order as it would read the original property,
143
+ // so the property is read lazily and `toJSON` is called once and with the original key
144
+ var createElementHolder = function (holder, key) {
145
+ return {
146
+ toJSON: function () {
147
+ var element = holder[key];
148
+ if (isObject(element) || typeof element == 'bigint') {
149
+ var elementToJSON = element.toJSON;
150
+ if (isCallable(elementToJSON)) element = call(elementToJSON, element, key);
151
+ } return element;
92
152
  }
93
- if (isArray(this)) return value;
94
- for (var j = 0; j < keysLength; j++) if (keys[j] === key) return value;
95
153
  };
96
154
  };
97
155
 
156
+ // own keys of objects are sorted - integer-like keys are moved to the beginning,
157
+ // so such keys should be marked and restored in the serialized string
158
+ var getKeyPrefix = function (propertyList) {
159
+ for (var i = 0, length = propertyList.length; i < length; i++) {
160
+ if (exec(digits, propertyList[i])) return KEY_MARK;
161
+ } return '';
162
+ };
163
+
164
+ // `SerializeJSONObject` iterates the property list, so the value is replaced with an object with keys in this order
165
+ var createOrderedObject = function (value, propertyList, keyPrefix) {
166
+ // keys are not marked if the property list has no integer-like keys, so `Object.prototype`
167
+ // with a setter, a non-writable property or `__proto__` should not intercept the assignment
168
+ var ordered = create(null);
169
+ for (var i = 0, length = propertyList.length; i < length; i++) {
170
+ var key = propertyList[i];
171
+ ordered[keyPrefix + key] = createElementHolder(value, key);
172
+ }
173
+ ordered[END_MARK] = null;
174
+ return ordered;
175
+ };
176
+
98
177
  // `JSON.stringify` method
99
178
  // https://tc39.es/ecma262/#sec-json.stringify
100
179
  // https://github.com/tc39/proposal-json-parse-with-source
101
180
  if ($stringify) $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE || !NATIVE_RAW_JSON }, {
102
181
  stringify: function stringify(text, replacer, space) {
103
- var replacerFunction = getReplacerFunction(replacer);
182
+ var replacerFunction = isCallable(replacer) ? replacer : undefined;
183
+ var propertyList = replacerFunction ? undefined : getPropertyList(replacer);
184
+ var keyPrefix = propertyList && getKeyPrefix(propertyList);
104
185
  var rawStrings = [];
186
+ var openObjects = [];
187
+ var parentOrdered = [];
188
+ var currentOrdered;
189
+ var marked = false;
190
+ var root = true;
105
191
 
106
192
  var json = stringifyWithProperSymbolsConversion(text, function (key, value) {
107
193
  // some old implementations (like WebKit) could pass numbers as keys
108
- var v = isCallable(replacerFunction) ? call(replacerFunction, this, $String(key), value) : value;
109
- return !NATIVE_RAW_JSON && isRawJSON(v) ? MARK + (push(rawStrings, v.rawJSON) - 1) : v;
194
+ key = $String(key);
195
+
196
+ if (propertyList) {
197
+ if (key === END_MARK) {
198
+ pop(openObjects);
199
+ currentOrdered = pop(parentOrdered);
200
+ return;
201
+ }
202
+ if (root) root = false;
203
+ // the innermost reordered object already contains only keys of the property list and arrays are not
204
+ // affected by it, the rest of objects (like objects with a fake `Symbol.toStringTag`) are filtered here
205
+ else if (this !== currentOrdered && !isArray(this) && !includes(propertyList, key)) return;
206
+ } else if (replacerFunction) value = call(replacerFunction, this, key, value);
207
+
208
+ if (isRawJSONValue(value)) {
209
+ if (NATIVE_RAW_JSON) return value;
210
+ marked = true;
211
+ return RAW_MARK + (push(rawStrings, value.rawJSON) - 1);
212
+ }
213
+
214
+ if (propertyList && isSerializedAsObject(value)) {
215
+ // reordered objects are new each time, so cycles should be detected before the engine does it
216
+ if (includes(openObjects, value)) throw new $TypeError('Converting circular structure to JSON');
217
+ var ordered = createOrderedObject(value, propertyList, keyPrefix);
218
+ push(openObjects, value);
219
+ push(parentOrdered, currentOrdered);
220
+ currentOrdered = ordered;
221
+ if (keyPrefix) marked = true;
222
+ return ordered;
223
+ }
224
+
225
+ return value;
110
226
  }, space);
111
227
 
112
228
  if (typeof json != 'string') return json;
113
229
 
114
230
  if (ILL_FORMED_UNICODE) json = replace(json, surrogates, fixIllFormedJSON);
115
231
 
116
- if (NATIVE_RAW_JSON) return json;
232
+ if (!marked) return json;
117
233
 
118
234
  var result = '';
119
235
  var length = json.length;
@@ -123,9 +239,9 @@ if ($stringify) $({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_
123
239
  if (chr === '"') {
124
240
  var end = parseJSONString(json, ++i).end - 1;
125
241
  var string = slice(json, i, end);
126
- result += slice(string, 0, MARK_LENGTH) === MARK
127
- ? rawStrings[slice(string, MARK_LENGTH)]
128
- : '"' + string + '"';
242
+ if (slice(string, 0, RAW_MARK_LENGTH) === RAW_MARK) result += rawStrings[slice(string, RAW_MARK_LENGTH)];
243
+ else if (slice(string, 0, KEY_MARK_LENGTH) === KEY_MARK) result += '"' + slice(string, KEY_MARK_LENGTH) + '"';
244
+ else result += '"' + string + '"';
129
245
  i = end;
130
246
  } else result += chr;
131
247
  }
@@ -4,6 +4,7 @@ var uncurryThis = require('../internals/function-uncurry-this');
4
4
  var aCallable = require('../internals/a-callable');
5
5
  var requireObjectCoercible = require('../internals/require-object-coercible');
6
6
  var iterate = require('../internals/iterate');
7
+ var doesNotExceedSafeInteger = require('../internals/does-not-exceed-safe-integer');
7
8
  var MapHelpers = require('../internals/map-helpers');
8
9
  var IS_PURE = require('../internals/is-pure');
9
10
  var fails = require('../internals/fails');
@@ -30,6 +31,7 @@ $({ target: 'Map', stat: true, forced: IS_PURE || DOES_NOT_WORK_WITH_PRIMITIVES
30
31
  var map = new Map();
31
32
  var k = 0;
32
33
  iterate(items, function (value) {
34
+ doesNotExceedSafeInteger(k);
33
35
  var key = callbackfn(value, k++);
34
36
  if (!has(map, key)) set(map, key, [value]);
35
37
  else push(get(map, key), value);
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
  var $ = require('../internals/export');
3
+ var log1p = require('../internals/math-log1p');
3
4
 
4
5
  // eslint-disable-next-line es/no-math-asinh -- required for testing
5
6
  var $asinh = Math.asinh;
7
+ var abs = Math.abs;
6
8
  var log = Math.log;
7
9
  var sqrt = Math.sqrt;
8
10
  var LN2 = Math.LN2;
@@ -11,14 +13,16 @@ var SQRT_2_POW_53 = 94906265.62425156;
11
13
 
12
14
  function asinh(x) {
13
15
  var n = +x;
14
- return !isFinite(n) || n === 0 ? n : n < 0 ? -asinh(-n) : n > SQRT_2_POW_53 ? log(n) + LN2 : log(n + sqrt(n * n + 1));
16
+ return !isFinite(n) || n === 0 ? n : n < 0 ? -asinh(-n) : n > SQRT_2_POW_53 ? log(n) + LN2
17
+ : n < 1e-8 ? n : log1p(n + n * n / (1 + sqrt(n * n + 1)));
15
18
  }
16
19
 
17
- var FORCED = !($asinh && 1 / $asinh(0) > 0);
20
+ // Tor Browser bug: Math.asinh(0) -> -0
21
+ // imprecise in V8 < 5.4 and Rhino
22
+ var FORCED = !($asinh && 1 / $asinh(0) > 0 && abs($asinh(1e-8) - 1e-8) < 1e-16);
18
23
 
19
24
  // `Math.asinh` method
20
25
  // https://tc39.es/ecma262/#sec-math.asinh
21
- // Tor Browser bug: Math.asinh(0) -> -0
22
26
  $({ target: 'Math', stat: true, forced: FORCED }, {
23
27
  asinh: asinh
24
28
  });
@@ -2,14 +2,21 @@
2
2
  var $ = require('../internals/export');
3
3
  var sign = require('../internals/math-sign');
4
4
 
5
+ // eslint-disable-next-line es/no-math-cbrt -- required for testing
6
+ var $cbrt = Math.cbrt;
5
7
  var abs = Math.abs;
6
8
  var pow = Math.pow;
7
9
 
10
+ // imprecise in FF < 48 (`cbrt(64)`) and with glibc `cbrt` (`cbrt(27)`), each check catches only one of them
11
+ var FORCED = !$cbrt || $cbrt(27) !== 3 || $cbrt(64) !== 4;
12
+
8
13
  // `Math.cbrt` method
9
14
  // https://tc39.es/ecma262/#sec-math.cbrt
10
- $({ target: 'Math', stat: true }, {
15
+ $({ target: 'Math', stat: true, forced: FORCED }, {
11
16
  cbrt: function cbrt(x) {
12
17
  var n = +x;
13
- return sign(n) * pow(abs(n), 1 / 3);
18
+ var y = sign(n) * pow(abs(n), 1 / 3);
19
+ // Newton-Raphson refinement for better precision
20
+ return n !== 0 && isFinite(n) ? (2 * y + n / (y * y)) / 3 : y;
14
21
  }
15
22
  });
@@ -4,14 +4,21 @@
4
4
  var $ = require('../internals/export');
5
5
  var uncurryThis = require('../internals/function-uncurry-this');
6
6
  var iterate = require('../internals/iterate');
7
+ var fails = require('../internals/fails');
8
+ var getIterator = require('../internals/get-iterator-internal');
9
+ var setPrototypeOf = require('../internals/object-set-prototype-of');
10
+ var wellKnownSymbol = require('../internals/well-known-symbol');
7
11
 
8
12
  var $RangeError = RangeError;
9
13
  var $TypeError = TypeError;
10
14
  var $Infinity = Infinity;
11
15
  var $NaN = NaN;
16
+ // eslint-disable-next-line es/no-math-sumprecise -- required for testing
17
+ var $sumPrecise = Math.sumPrecise;
12
18
  var abs = Math.abs;
13
19
  var pow = Math.pow;
14
20
  var push = uncurryThis([].push);
21
+ var ITERATOR = wellKnownSymbol('iterator');
15
22
 
16
23
  var POW_2_1023 = pow(2, 1023);
17
24
  var MAX_SAFE_INTEGER = pow(2, 53) - 1; // 2 ** 53 - 1 === 9007199254740991
@@ -24,6 +31,25 @@ var PLUS_INFINITY = {};
24
31
  var MINUS_ZERO = {};
25
32
  var FINITE = {};
26
33
 
34
+ // https://bugs.webkit.org/show_bug.cgi?id=315450
35
+ var FORCED = fails(function () {
36
+ if ($sumPrecise([-1]) !== -1 || $sumPrecise([-MAX_DOUBLE]) !== -MAX_DOUBLE) return true;
37
+ if (!setPrototypeOf) return false;
38
+ // https://issues.chromium.org/issues/500536164
39
+ try {
40
+ $sumPrecise(setPrototypeOf([1], {}));
41
+ return true;
42
+ } catch (error) { /* empty */ }
43
+ // https://issues.chromium.org/issues/572987948
44
+ try {
45
+ var prototype = {};
46
+ // eslint-disable-next-line unicorn/no-immediate-mutation -- ES3-compatible computed property
47
+ prototype[ITERATOR] = function () { return this; };
48
+ $sumPrecise(setPrototypeOf(getIterator([1]), prototype));
49
+ return true;
50
+ } catch (error) { /* empty */ }
51
+ });
52
+
27
53
  // prerequisite: abs(x) >= abs(y)
28
54
  var twosum = function (x, y) {
29
55
  var hi = x + y;
@@ -33,7 +59,7 @@ var twosum = function (x, y) {
33
59
 
34
60
  // `Math.sumPrecise` method
35
61
  // https://tc39.es/ecma262/#sec-math.sumprecise
36
- $({ target: 'Math', stat: true }, {
62
+ $({ target: 'Math', stat: true, forced: FORCED }, {
37
63
  // eslint-disable-next-line max-statements -- ok
38
64
  sumPrecise: function sumPrecise(items) {
39
65
  var numbers = [];
@@ -7,6 +7,7 @@ var aCallable = require('../internals/a-callable');
7
7
  var requireObjectCoercible = require('../internals/require-object-coercible');
8
8
  var toPropertyKey = require('../internals/to-property-key');
9
9
  var iterate = require('../internals/iterate');
10
+ var doesNotExceedSafeInteger = require('../internals/does-not-exceed-safe-integer');
10
11
  var fails = require('../internals/fails');
11
12
 
12
13
  // eslint-disable-next-line es/no-object-groupby -- testing
@@ -30,6 +31,7 @@ $({ target: 'Object', stat: true, forced: DOES_NOT_WORK_WITH_PRIMITIVES }, {
30
31
  var obj = create(null);
31
32
  var k = 0;
32
33
  iterate(items, function (value) {
34
+ doesNotExceedSafeInteger(k);
33
35
  var key = toPropertyKey(callbackfn(value, k++));
34
36
  // in some IE versions, `hasOwnProperty` returns incorrect result on integer keys
35
37
  // but since it's a `null` prototype object, we can safely use `in`
@@ -15,7 +15,8 @@ var PROTO = '__proto__';
15
15
 
16
16
  // `Object.prototype.__proto__` accessor
17
17
  // https://tc39.es/ecma262/#sec-object.prototype.__proto__
18
- if (DESCRIPTORS && getPrototypeOf && setPrototypeOf && !(PROTO in ObjectPrototype)) try {
18
+ // Deno 2.9+ patch this accessor, so we can't use `in` for feature detection
19
+ if (DESCRIPTORS && getPrototypeOf && setPrototypeOf && ({}[PROTO] !== ObjectPrototype)) try {
19
20
  defineBuiltInAccessor(ObjectPrototype, PROTO, {
20
21
  configurable: true,
21
22
  get: function __proto__() {
@@ -3,31 +3,39 @@ var $ = require('../internals/export');
3
3
  var globalThis = require('../internals/global-this');
4
4
  var apply = require('../internals/function-apply');
5
5
  var slice = require('../internals/array-slice');
6
+ var promiseResolve = require('../internals/promise-resolve');
6
7
  var newPromiseCapabilityModule = require('../internals/new-promise-capability');
7
8
  var aCallable = require('../internals/a-callable');
8
9
  var perform = require('../internals/perform');
10
+ var fails = require('../internals/fails');
9
11
 
10
12
  var Promise = globalThis.Promise;
11
13
 
12
14
  var ACCEPT_ARGUMENTS = false;
13
- // Avoiding the use of polyfills of the previous iteration of this proposal
14
- // that does not accept arguments of the callback
15
- var FORCED = !Promise || !Promise['try'] || perform(function () {
16
- Promise['try'](function (argument) {
15
+ var FORCED = !Promise || !Promise['try'] || fails(function () {
16
+ var p = Promise.resolve();
17
+ return Promise['try'](function (argument) {
18
+ // avoiding the use of polyfills of the previous iteration of this proposal
19
+ // that does not accept arguments of the callback
17
20
  ACCEPT_ARGUMENTS = argument === 8;
18
- }, 8);
19
- }).error || !ACCEPT_ARGUMENTS;
21
+ return p;
22
+ // it should use `PromiseResolve`
23
+ // https://github.com/tc39/ecma262/pull/3883
24
+ }, 8) !== p;
25
+ }) || !ACCEPT_ARGUMENTS;
20
26
 
21
27
  // `Promise.try` method
22
28
  // https://tc39.es/ecma262/#sec-promise.try
23
29
  $({ target: 'Promise', stat: true, forced: FORCED }, {
24
30
  'try': function (callbackfn /* , ...args */) {
25
31
  var args = arguments.length > 1 ? slice(arguments, 1) : [];
26
- var promiseCapability = newPromiseCapabilityModule.f(this);
27
32
  var result = perform(function () {
28
33
  return apply(aCallable(callbackfn), undefined, args);
29
34
  });
30
- (result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
35
+ if (!result.error) return promiseResolve(this, result.value);
36
+ var promiseCapability = newPromiseCapabilityModule.f(this);
37
+ var reject = promiseCapability.reject;
38
+ reject(result.value);
31
39
  return promiseCapability.promise;
32
40
  }
33
41
  });
@@ -31,7 +31,8 @@ var escapeChar = function (chr) {
31
31
  };
32
32
 
33
33
  // Avoiding the use of polyfills of the previous iteration of this proposal
34
- var FORCED = !$escape || $escape('ab') !== '\\x61b';
34
+ // and implementations with the WebKit bug https://bugs.webkit.org/show_bug.cgi?id=323642
35
+ var FORCED = !$escape || $escape('ab\uD840\uDC2A') !== '\\x61b\uD840\uDC2A';
35
36
 
36
37
  // `RegExp.escape` method
37
38
  // https://tc39.es/ecma262/#sec-regexp.escape
@@ -69,10 +69,9 @@ var $matchAll = function (string) {
69
69
  var S = toString(string);
70
70
  var C = speciesConstructor(R, RegExp);
71
71
  var flags = toString(getRegExpFlags(R));
72
- var matcher, $global, fullUnicode;
73
- matcher = new C(C === RegExp ? R.source : R, flags);
74
- $global = !!~stringIndexOf(flags, 'g');
75
- fullUnicode = !!~stringIndexOf(flags, 'u') || !!~stringIndexOf(flags, 'v');
72
+ var matcher = new C(C === RegExp ? R.source : R, flags);
73
+ var $global = !!~stringIndexOf(flags, 'g');
74
+ var fullUnicode = !!~stringIndexOf(flags, 'u') || !!~stringIndexOf(flags, 'v');
76
75
  matcher.lastIndex = toLength(R.lastIndex);
77
76
  return new $RegExpStringIterator(matcher, S, $global, fullUnicode);
78
77
  };
@@ -22,7 +22,9 @@ fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNa
22
22
  function match(regexp) {
23
23
  var O = requireObjectCoercible(this);
24
24
  var matcher = isObject(regexp) ? getMethod(regexp, MATCH) : undefined;
25
- return matcher ? call(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString(O));
25
+ if (matcher) return call(matcher, regexp, O);
26
+ var S = toString(O);
27
+ return new RegExp(regexp)[MATCH](S);
26
28
  },
27
29
  // `RegExp.prototype[@@match]` method
28
30
  // https://tc39.es/ecma262/#sec-regexp.prototype-@@match
@@ -17,7 +17,9 @@ fixRegExpWellKnownSymbolLogic('search', function (SEARCH, nativeSearch, maybeCal
17
17
  function search(regexp) {
18
18
  var O = requireObjectCoercible(this);
19
19
  var searcher = isObject(regexp) ? getMethod(regexp, SEARCH) : undefined;
20
- return searcher ? call(searcher, regexp, O) : new RegExp(regexp)[SEARCH](toString(O));
20
+ if (searcher) return call(searcher, regexp, O);
21
+ var S = toString(O);
22
+ return new RegExp(regexp)[SEARCH](S);
21
23
  },
22
24
  // `RegExp.prototype[@@search]` method
23
25
  // https://tc39.es/ecma262/#sec-regexp.prototype-@@search
@@ -1,4 +1,5 @@
1
1
  'use strict';
2
+ /* eslint-disable no-useless-assignment -- false positive for [index++] syntax */
2
3
  var $ = require('../internals/export');
3
4
  var globalThis = require('../internals/global-this');
4
5
  var uncurryThis = require('../internals/function-uncurry-this');
@@ -10,10 +11,14 @@ var getAlphabetOption = require('../internals/get-alphabet-option');
10
11
 
11
12
  var base64Alphabet = base64Map.i2c;
12
13
  var base64UrlAlphabet = base64Map.i2cUrl;
14
+ var $floor = Math.floor;
15
+ var $ceil = Math.ceil;
13
16
 
14
17
  var charAt = uncurryThis(''.charAt);
15
18
 
16
19
  var Uint8Array = globalThis.Uint8Array;
20
+ var $Array = globalThis.Array;
21
+ var join = uncurryThis([].join);
17
22
 
18
23
  var INCORRECT_BEHAVIOR_OR_DOESNT_EXISTS = !Uint8Array || !Uint8Array.prototype.toBase64 || !function () {
19
24
  try {
@@ -34,9 +39,10 @@ if (Uint8Array) $({ target: 'Uint8Array', proto: true, forced: INCORRECT_BEHAVIO
34
39
  var omitPadding = !!options && !!options.omitPadding;
35
40
  notDetached(this.buffer);
36
41
 
37
- var result = '';
38
42
  var i = 0;
39
43
  var length = array.length;
44
+ var result = $Array(omitPadding ? $floor(length / 3) * 4 + (length % 3 ? length % 3 + 1 : 0) : $ceil(length / 3) * 4);
45
+ var written = 0;
40
46
  var triplet;
41
47
 
42
48
  var at = function (shift) {
@@ -45,16 +51,27 @@ if (Uint8Array) $({ target: 'Uint8Array', proto: true, forced: INCORRECT_BEHAVIO
45
51
 
46
52
  for (; i + 2 < length; i += 3) {
47
53
  triplet = (array[i] << 16) + (array[i + 1] << 8) + array[i + 2];
48
- result += at(3) + at(2) + at(1) + at(0);
54
+ result[written++] = at(3);
55
+ result[written++] = at(2);
56
+ result[written++] = at(1);
57
+ result[written++] = at(0);
49
58
  }
50
59
  if (i + 2 === length) {
51
60
  triplet = (array[i] << 16) + (array[i + 1] << 8);
52
- result += at(3) + at(2) + at(1) + (omitPadding ? '' : '=');
61
+ result[written++] = at(3);
62
+ result[written++] = at(2);
63
+ result[written++] = at(1);
64
+ if (!omitPadding) result[written++] = '=';
53
65
  } else if (i + 1 === length) {
54
66
  triplet = array[i] << 16;
55
- result += at(3) + at(2) + (omitPadding ? '' : '==');
67
+ result[written++] = at(3);
68
+ result[written++] = at(2);
69
+ if (!omitPadding) {
70
+ result[written++] = '=';
71
+ result[written++] = '=';
72
+ }
56
73
  }
57
74
 
58
- return result;
75
+ return join(result, '');
59
76
  }
60
77
  });
@@ -1,44 +1,3 @@
1
1
  'use strict';
2
- var $ = require('../internals/export');
3
- var anObject = require('../internals/an-object');
4
- var call = require('../internals/function-call');
5
- var createIteratorProxy = require('../internals/iterator-create-proxy');
6
- var getIteratorDirect = require('../internals/get-iterator-direct');
7
- var iteratorClose = require('../internals/iterator-close');
8
- var uncurryThis = require('../internals/function-uncurry-this');
9
-
10
- var $RangeError = RangeError;
11
- var push = uncurryThis([].push);
12
-
13
- var IteratorProxy = createIteratorProxy(function () {
14
- var iterator = this.iterator;
15
- var next = this.next;
16
- var chunkSize = this.chunkSize;
17
- var buffer = [];
18
- var result, done;
19
- while (true) {
20
- result = anObject(call(next, iterator));
21
- done = !!result.done;
22
- if (done) {
23
- if (buffer.length) return buffer;
24
- this.done = true;
25
- return;
26
- }
27
- push(buffer, result.value);
28
- if (buffer.length === chunkSize) return buffer;
29
- }
30
- });
31
-
32
- // `Iterator.prototype.chunks` method
33
- // https://github.com/tc39/proposal-iterator-chunking
34
- $({ target: 'Iterator', proto: true, real: true, forced: true }, {
35
- chunks: function chunks(chunkSize) {
36
- var O = anObject(this);
37
- if (typeof chunkSize != 'number' || !chunkSize || chunkSize >>> 0 !== chunkSize) {
38
- return iteratorClose(O, 'throw', new $RangeError('chunkSize must be integer in [1, 2^32-1]'));
39
- }
40
- return new IteratorProxy(getIteratorDirect(O), {
41
- chunkSize: chunkSize
42
- });
43
- }
44
- });
2
+ // TODO: Remove from `core-js@4`
3
+ require('../modules/es.iterator.chunks');
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ // TODO: Remove from `core-js@4`
3
+ require('../modules/es.iterator.includes');
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ // TODO: Remove from `core-js@4`
3
+ require('../modules/es.iterator.join');
@@ -1,11 +1,3 @@
1
1
  'use strict';
2
- var $ = require('../internals/export');
3
- var iteratorWindow = require('../internals/iterator-window');
4
-
5
- // `Iterator.prototype.windows` method
6
- // https://github.com/tc39/proposal-iterator-chunking
7
- $({ target: 'Iterator', proto: true, real: true, forced: true }, {
8
- windows: function windows(windowSize /* , undersized */) {
9
- return iteratorWindow(this, windowSize, arguments.length < 2 ? undefined : arguments[1]);
10
- }
11
- });
2
+ // TODO: Remove from `core-js@4`
3
+ require('../modules/es.iterator.windows');