core-js 3.11.1 → 3.12.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/features/index.js CHANGED
@@ -326,6 +326,8 @@ require('../modules/esnext.string.match-all');
326
326
  require('../modules/esnext.string.replace-all');
327
327
  require('../modules/esnext.symbol.async-dispose');
328
328
  require('../modules/esnext.symbol.dispose');
329
+ require('../modules/esnext.symbol.matcher');
330
+ require('../modules/esnext.symbol.metadata');
329
331
  require('../modules/esnext.symbol.observable');
330
332
  require('../modules/esnext.symbol.pattern-match');
331
333
  require('../modules/esnext.symbol.replace-all');
@@ -1,7 +1,10 @@
1
1
  var parent = require('../../es/symbol');
2
2
  require('../../modules/esnext.symbol.async-dispose');
3
3
  require('../../modules/esnext.symbol.dispose');
4
+ require('../../modules/esnext.symbol.matcher');
5
+ require('../../modules/esnext.symbol.metadata');
4
6
  require('../../modules/esnext.symbol.observable');
7
+ // TODO: Remove from `core-js@4`
5
8
  require('../../modules/esnext.symbol.pattern-match');
6
9
  // TODO: Remove from `core-js@4`
7
10
  require('../../modules/esnext.symbol.replace-all');
@@ -0,0 +1,4 @@
1
+ require('../../modules/esnext.symbol.matcher');
2
+ var WrappedWellKnownSymbolModule = require('../../internals/well-known-symbol-wrapped');
3
+
4
+ module.exports = WrappedWellKnownSymbolModule.f('matcher');
@@ -0,0 +1,4 @@
1
+ require('../../modules/esnext.symbol.metadata');
2
+ var WrappedWellKnownSymbolModule = require('../../internals/well-known-symbol-wrapped');
3
+
4
+ module.exports = WrappedWellKnownSymbolModule.f('metadata');
@@ -1,3 +1,4 @@
1
+ // TODO: Remove from `core-js@4`
1
2
  require('../../modules/esnext.symbol.pattern-match');
2
3
  var WrappedWellKnownSymbolModule = require('../../internals/well-known-symbol-wrapped');
3
4
 
@@ -0,0 +1 @@
1
+ module.exports = typeof window == 'object';
@@ -8,7 +8,7 @@ var match, version;
8
8
 
9
9
  if (v8) {
10
10
  match = v8.split('.');
11
- version = match[0] + match[1];
11
+ version = match[0] < 4 ? 1 : match[0] + match[1];
12
12
  } else if (userAgent) {
13
13
  match = userAgent.match(/Edge\/(\d+)/);
14
14
  if (!match || match[1] >= 74) {
@@ -2,11 +2,13 @@
2
2
  // TODO: Remove from `core-js@4` since it's moved to entry points
3
3
  require('../modules/es.regexp.exec');
4
4
  var redefine = require('../internals/redefine');
5
+ var regexpExec = require('../internals/regexp-exec');
5
6
  var fails = require('../internals/fails');
6
7
  var wellKnownSymbol = require('../internals/well-known-symbol');
7
8
  var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
8
9
 
9
10
  var SPECIES = wellKnownSymbol('species');
11
+ var RegExpPrototype = RegExp.prototype;
10
12
 
11
13
  var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
12
14
  // #replace needs built-in support for named groups.
@@ -94,7 +96,8 @@ module.exports = function (KEY, length, exec, sham) {
94
96
  ) {
95
97
  var nativeRegExpMethod = /./[SYMBOL];
96
98
  var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
97
- if (regexp.exec === RegExp.prototype.exec) {
99
+ var $exec = regexp.exec;
100
+ if ($exec === regexpExec || $exec === RegExpPrototype.exec) {
98
101
  if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
99
102
  // The native String method already delegates to @@method (this
100
103
  // polyfilled function), leasing to infinite recursion.
@@ -112,7 +115,7 @@ module.exports = function (KEY, length, exec, sham) {
112
115
  var regexMethod = methods[1];
113
116
 
114
117
  redefine(String.prototype, KEY, stringMethod);
115
- redefine(RegExp.prototype, SYMBOL, length == 2
118
+ redefine(RegExpPrototype, SYMBOL, length == 2
116
119
  // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
117
120
  // 21.2.5.11 RegExp.prototype[@@split](string, limit)
118
121
  ? function (string, arg) { return regexMethod.call(string, this, arg); }
@@ -122,5 +125,5 @@ module.exports = function (KEY, length, exec, sham) {
122
125
  );
123
126
  }
124
127
 
125
- if (sham) createNonEnumerableProperty(RegExp.prototype[SYMBOL], 'sham', true);
128
+ if (sham) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
126
129
  };
@@ -24,7 +24,7 @@ var getterFor = function (TYPE) {
24
24
  };
25
25
  };
26
26
 
27
- if (NATIVE_WEAK_MAP) {
27
+ if (NATIVE_WEAK_MAP || shared.state) {
28
28
  var store = shared.state || (shared.state = new WeakMap());
29
29
  var wmget = store.get;
30
30
  var wmhas = store.has;
@@ -47,6 +47,8 @@ if (!queueMicrotask) {
47
47
  } else if (Promise && Promise.resolve) {
48
48
  // Promise.resolve without an argument throws an error in LG WebOS 2
49
49
  promise = Promise.resolve(undefined);
50
+ // workaround of WebKit ~ iOS Safari 10.1 bug
51
+ promise.constructor = Promise;
50
52
  then = promise.then;
51
53
  notify = function () {
52
54
  then.call(promise, flush);
@@ -1,12 +1,11 @@
1
- var IS_NODE = require('../internals/engine-is-node');
1
+ /* eslint-disable es/no-symbol -- required for testing */
2
2
  var V8_VERSION = require('../internals/engine-v8-version');
3
3
  var fails = require('../internals/fails');
4
4
 
5
5
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
6
6
  module.exports = !!Object.getOwnPropertySymbols && !fails(function () {
7
- // eslint-disable-next-line es/no-symbol -- required for testing
8
- return !Symbol.sham &&
7
+ return !String(Symbol()) ||
9
8
  // Chrome 38 Symbol has incorrect toString conversion
10
9
  // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
11
- (IS_NODE ? V8_VERSION === 38 : V8_VERSION > 37 && V8_VERSION < 41);
10
+ !Symbol.sham && V8_VERSION && V8_VERSION < 41;
12
11
  });
@@ -1,4 +1,6 @@
1
1
  'use strict';
2
+ /* eslint-disable regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
3
+ /* eslint-disable regexp/no-useless-quantifier -- testing */
2
4
  var regexpFlags = require('./regexp-flags');
3
5
  var stickyHelpers = require('./regexp-sticky-helpers');
4
6
  var shared = require('./shared');
@@ -19,7 +21,6 @@ var UPDATES_LAST_INDEX_WRONG = (function () {
19
21
  var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y || stickyHelpers.BROKEN_CARET;
20
22
 
21
23
  // nonparticipating capturing group, copied from es5-shim's String#split patch.
22
- // eslint-disable-next-line regexp/no-assertion-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing
23
24
  var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
24
25
 
25
26
  var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y;
@@ -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.11.1',
7
+ version: '3.12.1',
8
8
  mode: IS_PURE ? 'pure' : 'global',
9
9
  copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
10
10
  });
@@ -30,7 +30,10 @@ $({ target: 'Promise', proto: true, real: true, forced: NON_GENERIC }, {
30
30
  }
31
31
  });
32
32
 
33
- // patch native Promise.prototype for native async functions
34
- if (!IS_PURE && typeof NativePromise == 'function' && !NativePromise.prototype['finally']) {
35
- redefine(NativePromise.prototype, 'finally', getBuiltIn('Promise').prototype['finally']);
33
+ // makes sure that native promise-based APIs `Promise#finally` properly works with patched `Promise#then`
34
+ if (!IS_PURE && typeof NativePromise == 'function') {
35
+ var method = getBuiltIn('Promise').prototype['finally'];
36
+ if (NativePromise.prototype['finally'] !== method) {
37
+ redefine(NativePromise.prototype, 'finally', method, { unsafe: true });
38
+ }
36
39
  }
@@ -25,6 +25,7 @@ var perform = require('../internals/perform');
25
25
  var InternalStateModule = require('../internals/internal-state');
26
26
  var isForced = require('../internals/is-forced');
27
27
  var wellKnownSymbol = require('../internals/well-known-symbol');
28
+ var IS_BROWSER = require('../internals/engine-is-browser');
28
29
  var IS_NODE = require('../internals/engine-is-node');
29
30
  var V8_VERSION = require('../internals/engine-v8-version');
30
31
 
@@ -35,6 +36,7 @@ var setInternalState = InternalStateModule.set;
35
36
  var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
36
37
  var NativePromisePrototype = NativePromise && NativePromise.prototype;
37
38
  var PromiseConstructor = NativePromise;
39
+ var PromiseConstructorPrototype = NativePromisePrototype;
38
40
  var TypeError = global.TypeError;
39
41
  var document = global.document;
40
42
  var process = global.process;
@@ -49,32 +51,32 @@ var FULFILLED = 1;
49
51
  var REJECTED = 2;
50
52
  var HANDLED = 1;
51
53
  var UNHANDLED = 2;
54
+ var SUBCLASSING = false;
52
55
  var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
53
56
 
54
57
  var FORCED = isForced(PROMISE, function () {
55
58
  var GLOBAL_CORE_JS_PROMISE = inspectSource(PromiseConstructor) !== String(PromiseConstructor);
56
- if (!GLOBAL_CORE_JS_PROMISE) {
57
- // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
58
- // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
59
- // We can't detect it synchronously, so just check versions
60
- if (V8_VERSION === 66) return true;
61
- // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
62
- if (!IS_NODE && !NATIVE_REJECTION_EVENT) return true;
63
- }
59
+ // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
60
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
61
+ // We can't detect it synchronously, so just check versions
62
+ if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
64
63
  // We need Promise#finally in the pure version for preventing prototype pollution
65
- if (IS_PURE && !PromiseConstructor.prototype['finally']) return true;
64
+ if (IS_PURE && !PromiseConstructorPrototype['finally']) return true;
66
65
  // We can't use @@species feature detection in V8 since it causes
67
66
  // deoptimization and performance degradation
68
67
  // https://github.com/zloirock/core-js/issues/679
69
68
  if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false;
70
69
  // Detect correctness of subclassing with @@species support
71
- var promise = PromiseConstructor.resolve(1);
70
+ var promise = new PromiseConstructor(function (resolve) { resolve(1); });
72
71
  var FakePromise = function (exec) {
73
72
  exec(function () { /* empty */ }, function () { /* empty */ });
74
73
  };
75
74
  var constructor = promise.constructor = {};
76
75
  constructor[SPECIES] = FakePromise;
77
- return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
76
+ SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
77
+ if (!SUBCLASSING) return true;
78
+ // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
79
+ return !GLOBAL_CORE_JS_PROMISE && IS_BROWSER && !NATIVE_REJECTION_EVENT;
78
80
  });
79
81
 
80
82
  var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
@@ -238,6 +240,7 @@ if (FORCED) {
238
240
  internalReject(state, error);
239
241
  }
240
242
  };
243
+ PromiseConstructorPrototype = PromiseConstructor.prototype;
241
244
  // eslint-disable-next-line no-unused-vars -- required for `.length`
242
245
  Internal = function Promise(executor) {
243
246
  setInternalState(this, {
@@ -251,7 +254,7 @@ if (FORCED) {
251
254
  value: undefined
252
255
  });
253
256
  };
254
- Internal.prototype = redefineAll(PromiseConstructor.prototype, {
257
+ Internal.prototype = redefineAll(PromiseConstructorPrototype, {
255
258
  // `Promise.prototype.then` method
256
259
  // https://tc39.es/ecma262/#sec-promise.prototype.then
257
260
  then: function then(onFulfilled, onRejected) {
@@ -287,14 +290,19 @@ if (FORCED) {
287
290
  if (!IS_PURE && typeof NativePromise == 'function' && NativePromisePrototype !== Object.prototype) {
288
291
  nativeThen = NativePromisePrototype.then;
289
292
 
290
- // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
291
- redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
292
- var that = this;
293
- return new PromiseConstructor(function (resolve, reject) {
294
- nativeThen.call(that, resolve, reject);
295
- }).then(onFulfilled, onRejected);
296
- // https://github.com/zloirock/core-js/issues/640
297
- }, { unsafe: true });
293
+ if (!SUBCLASSING) {
294
+ // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
295
+ redefine(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
296
+ var that = this;
297
+ return new PromiseConstructor(function (resolve, reject) {
298
+ nativeThen.call(that, resolve, reject);
299
+ }).then(onFulfilled, onRejected);
300
+ // https://github.com/zloirock/core-js/issues/640
301
+ }, { unsafe: true });
302
+
303
+ // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
304
+ redefine(NativePromisePrototype, 'catch', PromiseConstructorPrototype['catch'], { unsafe: true });
305
+ }
298
306
 
299
307
  // make `.constructor === Promise` work for native promise-based APIs
300
308
  try {
@@ -303,7 +311,7 @@ if (FORCED) {
303
311
 
304
312
  // make `instanceof Promise` work for native promise-based APIs
305
313
  if (setPrototypeOf) {
306
- setPrototypeOf(NativePromisePrototype, PromiseConstructor.prototype);
314
+ setPrototypeOf(NativePromisePrototype, PromiseConstructorPrototype);
307
315
  }
308
316
  }
309
317
  }
@@ -0,0 +1,5 @@
1
+ var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
2
+
3
+ // `Symbol.matcher` well-known symbol
4
+ // https://github.com/tc39/proposal-pattern-matching
5
+ defineWellKnownSymbol('matcher');
@@ -0,0 +1,5 @@
1
+ var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
2
+
3
+ // `Symbol.metadata` well-known symbol
4
+ // https://github.com/tc39/proposal-decorators
5
+ defineWellKnownSymbol('metadata');
@@ -1,3 +1,4 @@
1
+ // TODO: remove from `core-js@4`
1
2
  var defineWellKnownSymbol = require('../internals/define-well-known-symbol');
2
3
 
3
4
  // `Symbol.patternMatch` well-known symbol
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "core-js",
3
3
  "description": "Standard library",
4
- "version": "3.11.1",
4
+ "version": "3.12.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/zloirock/core-js.git",
@@ -55,5 +55,5 @@
55
55
  "scripts": {
56
56
  "postinstall": "node -e \"try{require('./postinstall')}catch(e){}\""
57
57
  },
58
- "gitHead": "1e9c4fbb22c7954d50a4db09d40d5c7648bead88"
58
+ "gitHead": "8752e6940ac87e35a05c7a0df53cdc781bb73c8d"
59
59
  }
@@ -0,0 +1,2 @@
1
+ // https://github.com/tc39/proposal-decorators
2
+ require('../modules/esnext.symbol.metadata');
@@ -1 +1,4 @@
1
+ // https://github.com/tc39/proposal-pattern-matching
2
+ require('../modules/esnext.symbol.matcher');
3
+ // TODO: remove from `core-js@4`
1
4
  require('../modules/esnext.symbol.pattern-match');
package/stage/2.js CHANGED
@@ -1,6 +1,7 @@
1
1
  require('../proposals/accessible-object-hasownproperty');
2
2
  require('../proposals/array-find-from-last');
3
3
  require('../proposals/array-is-template-object');
4
+ require('../proposals/decorators');
4
5
  require('../proposals/iterator-helpers');
5
6
  require('../proposals/map-upsert');
6
7
  require('../proposals/set-methods');