core-js-pure 3.3.1 → 3.3.5

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.
@@ -1,10 +1,14 @@
1
1
  var fails = require('../internals/fails');
2
2
  var wellKnownSymbol = require('../internals/well-known-symbol');
3
+ var V8_VERSION = require('../internals/v8-version');
3
4
 
4
5
  var SPECIES = wellKnownSymbol('species');
5
6
 
6
7
  module.exports = function (METHOD_NAME) {
7
- return !fails(function () {
8
+ // We can't use this feature detection in V8 since it causes
9
+ // deoptimization and serious performance degradation
10
+ // https://github.com/zloirock/core-js/issues/677
11
+ return V8_VERSION >= 51 || !fails(function () {
8
12
  var array = [];
9
13
  var constructor = array.constructor = {};
10
14
  constructor[SPECIES] = function () {
@@ -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.3.1',
7
+ version: '3.3.5',
8
8
  mode: IS_PURE ? 'pure' : 'global',
9
9
  copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
10
10
  });
@@ -0,0 +1,17 @@
1
+ var global = require('../internals/global');
2
+ var userAgent = require('../internals/user-agent');
3
+
4
+ var process = global.process;
5
+ var versions = process && process.versions;
6
+ var v8 = versions && versions.v8;
7
+ var match, version;
8
+
9
+ if (v8) {
10
+ match = v8.split('.');
11
+ version = match[0] + match[1];
12
+ } else if (userAgent) {
13
+ match = userAgent.match(/Chrome\/(\d+)/);
14
+ if (match) version = match[1];
15
+ }
16
+
17
+ module.exports = version && +version;
@@ -9,12 +9,16 @@ var createProperty = require('../internals/create-property');
9
9
  var arraySpeciesCreate = require('../internals/array-species-create');
10
10
  var arrayMethodHasSpeciesSupport = require('../internals/array-method-has-species-support');
11
11
  var wellKnownSymbol = require('../internals/well-known-symbol');
12
+ var V8_VERSION = require('../internals/v8-version');
12
13
 
13
14
  var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
14
15
  var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
15
16
  var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
16
17
 
17
- var IS_CONCAT_SPREADABLE_SUPPORT = !fails(function () {
18
+ // We can't use this feature detection in V8 since it causes
19
+ // deoptimization and serious performance degradation
20
+ // https://github.com/zloirock/core-js/issues/679
21
+ var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails(function () {
18
22
  var array = [];
19
23
  array[IS_CONCAT_SPREADABLE] = false;
20
24
  return array.concat()[0] !== array;
@@ -11,6 +11,7 @@ var test = [1, 2];
11
11
  // https://bugs.webkit.org/show_bug.cgi?id=188794
12
12
  $({ target: 'Array', proto: true, forced: String(test) === String(test.reverse()) }, {
13
13
  reverse: function reverse() {
14
+ // eslint-disable-next-line no-self-assign
14
15
  if (isArray(this)) this.length = this.length;
15
16
  return nativeReverse.call(this);
16
17
  }
@@ -2,7 +2,7 @@
2
2
  var $ = require('../internals/export');
3
3
  var IS_PURE = require('../internals/is-pure');
4
4
  var global = require('../internals/global');
5
- var path = require('../internals/path');
5
+ var getBuiltIn = require('../internals/get-built-in');
6
6
  var NativePromise = require('../internals/native-promise-constructor');
7
7
  var redefine = require('../internals/redefine');
8
8
  var redefineAll = require('../internals/redefine-all');
@@ -21,10 +21,10 @@ var promiseResolve = require('../internals/promise-resolve');
21
21
  var hostReportErrors = require('../internals/host-report-errors');
22
22
  var newPromiseCapabilityModule = require('../internals/new-promise-capability');
23
23
  var perform = require('../internals/perform');
24
- var userAgent = require('../internals/user-agent');
25
24
  var InternalStateModule = require('../internals/internal-state');
26
25
  var isForced = require('../internals/is-forced');
27
26
  var wellKnownSymbol = require('../internals/well-known-symbol');
27
+ var V8_VERSION = require('../internals/v8-version');
28
28
 
29
29
  var SPECIES = wellKnownSymbol('species');
30
30
  var PROMISE = 'Promise';
@@ -35,9 +35,7 @@ var PromiseConstructor = NativePromise;
35
35
  var TypeError = global.TypeError;
36
36
  var document = global.document;
37
37
  var process = global.process;
38
- var $fetch = global.fetch;
39
- var versions = process && process.versions;
40
- var v8 = versions && versions.v8 || '';
38
+ var $fetch = getBuiltIn('fetch');
41
39
  var newPromiseCapability = newPromiseCapabilityModule.f;
42
40
  var newGenericPromiseCapability = newPromiseCapability;
43
41
  var IS_NODE = classof(process) == 'process';
@@ -52,21 +50,26 @@ var UNHANDLED = 2;
52
50
  var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
53
51
 
54
52
  var FORCED = isForced(PROMISE, function () {
55
- // correct subclassing with @@species support
53
+ // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
54
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
55
+ // We can't detect it synchronously, so just check versions
56
+ if (V8_VERSION === 66) return true;
57
+ // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
58
+ if (!IS_NODE && typeof PromiseRejectionEvent != 'function') return true;
59
+ // We need Promise#finally in the pure version for preventing prototype pollution
60
+ if (IS_PURE && !PromiseConstructor.prototype['finally']) return true;
61
+ // We can't use @@species feature detection in V8 since it causes
62
+ // deoptimization and performance degradation
63
+ // https://github.com/zloirock/core-js/issues/679
64
+ if (V8_VERSION >= 51 && /native code/.test(PromiseConstructor)) return false;
65
+ // Detect correctness of subclassing with @@species support
56
66
  var promise = PromiseConstructor.resolve(1);
57
- var empty = function () { /* empty */ };
58
- var FakePromise = (promise.constructor = {})[SPECIES] = function (exec) {
59
- exec(empty, empty);
67
+ var FakePromise = function (exec) {
68
+ exec(function () { /* empty */ }, function () { /* empty */ });
60
69
  };
61
- // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
62
- return !((IS_NODE || typeof PromiseRejectionEvent == 'function')
63
- && (!IS_PURE || promise['finally'])
64
- && promise.then(empty) instanceof FakePromise
65
- // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
66
- // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
67
- // we can't detect it synchronously, so just check versions
68
- && v8.indexOf('6.6') !== 0
69
- && userAgent.indexOf('Chrome/66') === -1);
70
+ var constructor = promise.constructor = {};
71
+ constructor[SPECIES] = FakePromise;
72
+ return !(promise.then(function () { /* empty */ }) instanceof FakePromise);
70
73
  });
71
74
 
72
75
  var INCORRECT_ITERATION = FORCED || !checkCorrectnessOfIteration(function (iterable) {
@@ -289,7 +292,7 @@ if (FORCED) {
289
292
  // wrap fetch result
290
293
  if (typeof $fetch == 'function') $({ global: true, enumerable: true, forced: true }, {
291
294
  // eslint-disable-next-line no-unused-vars
292
- fetch: function fetch(input) {
295
+ fetch: function fetch(input /* , init */) {
293
296
  return promiseResolve(PromiseConstructor, $fetch.apply(global, arguments));
294
297
  }
295
298
  });
@@ -303,7 +306,7 @@ $({ global: true, wrap: true, forced: FORCED }, {
303
306
  setToStringTag(PromiseConstructor, PROMISE, false, true);
304
307
  setSpecies(PROMISE);
305
308
 
306
- PromiseWrapper = path[PROMISE];
309
+ PromiseWrapper = getBuiltIn(PROMISE);
307
310
 
308
311
  // statics
309
312
  $({ target: PROMISE, stat: true, forced: FORCED }, {
@@ -20,6 +20,10 @@ if (!has(AsyncIteratorPrototype, TO_STRING_TAG)) {
20
20
  createNonEnumerableProperty(AsyncIteratorPrototype, TO_STRING_TAG, 'AsyncIterator');
21
21
  }
22
22
 
23
+ if (!has(AsyncIteratorPrototype, 'constructor') || AsyncIteratorPrototype.constructor === Object) {
24
+ createNonEnumerableProperty(AsyncIteratorPrototype, 'constructor', AsyncIteratorConstructor);
25
+ }
26
+
23
27
  $({ global: true, forced: IS_PURE }, {
24
28
  AsyncIterator: AsyncIteratorConstructor
25
29
  });
@@ -32,6 +32,10 @@ if (!has(IteratorPrototype, TO_STRING_TAG)) {
32
32
  createNonEnumerableProperty(IteratorPrototype, TO_STRING_TAG, 'Iterator');
33
33
  }
34
34
 
35
+ if (!has(IteratorPrototype, 'constructor') || IteratorPrototype.constructor === Object) {
36
+ createNonEnumerableProperty(IteratorPrototype, 'constructor', IteratorConstructor);
37
+ }
38
+
35
39
  IteratorConstructor.prototype = IteratorPrototype;
36
40
 
37
41
  $({ global: true, forced: FORCED }, {
@@ -33,6 +33,7 @@ $({ target: 'String', proto: true }, {
33
33
  }
34
34
  string = String(O);
35
35
  searchString = String(searchValue);
36
+ if (searchString === '') return replaceAll.call(string, /(?:)/g, replaceValue);
36
37
  template = string.split(searchString);
37
38
  if (typeof replaceValue !== 'function') {
38
39
  return template.join(String(replaceValue));
@@ -2,6 +2,7 @@
2
2
  // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
3
3
  require('../modules/es.array.iterator');
4
4
  var $ = require('../internals/export');
5
+ var getBuiltIn = require('../internals/get-built-in');
5
6
  var USE_NATIVE_URL = require('../internals/native-url');
6
7
  var redefine = require('../internals/redefine');
7
8
  var redefineAll = require('../internals/redefine-all');
@@ -11,12 +12,17 @@ var InternalStateModule = require('../internals/internal-state');
11
12
  var anInstance = require('../internals/an-instance');
12
13
  var hasOwn = require('../internals/has');
13
14
  var bind = require('../internals/bind-context');
15
+ var classof = require('../internals/classof');
14
16
  var anObject = require('../internals/an-object');
15
17
  var isObject = require('../internals/is-object');
18
+ var create = require('../internals/object-create');
19
+ var createPropertyDescriptor = require('../internals/create-property-descriptor');
16
20
  var getIterator = require('../internals/get-iterator');
17
21
  var getIteratorMethod = require('../internals/get-iterator-method');
18
22
  var wellKnownSymbol = require('../internals/well-known-symbol');
19
23
 
24
+ var $fetch = getBuiltIn('fetch');
25
+ var Headers = getBuiltIn('Headers');
20
26
  var ITERATOR = wellKnownSymbol('iterator');
21
27
  var URL_SEARCH_PARAMS = 'URLSearchParams';
22
28
  var URL_SEARCH_PARAMS_ITERATOR = URL_SEARCH_PARAMS + 'Iterator';
@@ -307,6 +313,34 @@ $({ global: true, forced: !USE_NATIVE_URL }, {
307
313
  URLSearchParams: URLSearchParamsConstructor
308
314
  });
309
315
 
316
+ // Wrap `fetch` for correct work with polyfilled `URLSearchParams`
317
+ // https://github.com/zloirock/core-js/issues/674
318
+ if (!USE_NATIVE_URL && typeof $fetch == 'function' && typeof Headers == 'function') {
319
+ $({ global: true, enumerable: true, forced: true }, {
320
+ fetch: function fetch(input /* , init */) {
321
+ var args = [input];
322
+ var init, body, headers;
323
+ if (arguments.length > 1) {
324
+ init = arguments[1];
325
+ if (isObject(init)) {
326
+ body = init.body;
327
+ if (classof(body) === URL_SEARCH_PARAMS) {
328
+ headers = new Headers(init.headers);
329
+ if (!headers.has('content-type')) {
330
+ headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
331
+ }
332
+ init = create(init, {
333
+ body: createPropertyDescriptor(0, String(body)),
334
+ headers: createPropertyDescriptor(0, headers)
335
+ });
336
+ }
337
+ }
338
+ args.push(init);
339
+ } return $fetch.apply(this, args);
340
+ }
341
+ });
342
+ }
343
+
310
344
  module.exports = {
311
345
  URLSearchParams: URLSearchParamsConstructor,
312
346
  getState: getInternalParamsState
@@ -260,7 +260,6 @@ var percentEncode = function (char, set) {
260
260
  var specialSchemes = {
261
261
  ftp: 21,
262
262
  file: null,
263
- gopher: 70,
264
263
  http: 80,
265
264
  https: 443,
266
265
  ws: 80,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "core-js-pure",
3
3
  "description": "Standard library",
4
- "version": "3.3.1",
4
+ "version": "3.3.5",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/zloirock/core-js.git"
@@ -18,6 +18,7 @@
18
18
  "ES2017",
19
19
  "ES2018",
20
20
  "ES2019",
21
+ "ES2020",
21
22
  "ECMAScript 3",
22
23
  "ECMAScript 5",
23
24
  "ECMAScript 6",
@@ -27,6 +28,7 @@
27
28
  "ECMAScript 2017",
28
29
  "ECMAScript 2018",
29
30
  "ECMAScript 2019",
31
+ "ECMAScript 2020",
30
32
  "Harmony",
31
33
  "Strawman",
32
34
  "Map",