core-js 3.23.0 → 3.23.3

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.
@@ -15,7 +15,10 @@ var getPrototypeOf = require('../internals/object-get-prototype-of');
15
15
  var setPrototypeOf = require('../internals/object-set-prototype-of');
16
16
  var wellKnownSymbol = require('../internals/well-known-symbol');
17
17
  var uid = require('../internals/uid');
18
+ var InternalStateModule = require('../internals/internal-state');
18
19
 
20
+ var enforceInternalState = InternalStateModule.enforce;
21
+ var getInternalState = InternalStateModule.get;
19
22
  var Int8Array = global.Int8Array;
20
23
  var Int8ArrayPrototype = Int8Array && Int8Array.prototype;
21
24
  var Uint8ClampedArray = global.Uint8ClampedArray;
@@ -27,7 +30,7 @@ var TypeError = global.TypeError;
27
30
 
28
31
  var TO_STRING_TAG = wellKnownSymbol('toStringTag');
29
32
  var TYPED_ARRAY_TAG = uid('TYPED_ARRAY_TAG');
30
- var TYPED_ARRAY_CONSTRUCTOR = uid('TYPED_ARRAY_CONSTRUCTOR');
33
+ var TYPED_ARRAY_CONSTRUCTOR = 'TypedArrayConstructor';
31
34
  // Fixing native typed arrays in Opera Presto crashes the browser, see #595
32
35
  var NATIVE_ARRAY_BUFFER_VIEWS = NATIVE_ARRAY_BUFFER && !!setPrototypeOf && classof(global.opera) !== 'Opera';
33
36
  var TYPED_ARRAY_TAG_REQUIRED = false;
@@ -58,6 +61,13 @@ var isView = function isView(it) {
58
61
  || hasOwn(BigIntArrayConstructorsList, klass);
59
62
  };
60
63
 
64
+ var getTypedArrayConstructor = function (it) {
65
+ var proto = getPrototypeOf(it);
66
+ if (!isObject(proto)) return;
67
+ var state = getInternalState(proto);
68
+ return (state && hasOwn(state, TYPED_ARRAY_CONSTRUCTOR)) ? state[TYPED_ARRAY_CONSTRUCTOR] : getTypedArrayConstructor(proto);
69
+ };
70
+
61
71
  var isTypedArray = function (it) {
62
72
  if (!isObject(it)) return false;
63
73
  var klass = classof(it);
@@ -122,14 +132,14 @@ var exportTypedArrayStaticMethod = function (KEY, property, forced) {
122
132
  for (NAME in TypedArrayConstructorsList) {
123
133
  Constructor = global[NAME];
124
134
  Prototype = Constructor && Constructor.prototype;
125
- if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);
135
+ if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
126
136
  else NATIVE_ARRAY_BUFFER_VIEWS = false;
127
137
  }
128
138
 
129
139
  for (NAME in BigIntArrayConstructorsList) {
130
140
  Constructor = global[NAME];
131
141
  Prototype = Constructor && Constructor.prototype;
132
- if (Prototype) createNonEnumerableProperty(Prototype, TYPED_ARRAY_CONSTRUCTOR, Constructor);
142
+ if (Prototype) enforceInternalState(Prototype)[TYPED_ARRAY_CONSTRUCTOR] = Constructor;
133
143
  }
134
144
 
135
145
  // WebKit bug - typed arrays constructors prototype is Object.prototype
@@ -167,12 +177,12 @@ if (DESCRIPTORS && !hasOwn(TypedArrayPrototype, TO_STRING_TAG)) {
167
177
 
168
178
  module.exports = {
169
179
  NATIVE_ARRAY_BUFFER_VIEWS: NATIVE_ARRAY_BUFFER_VIEWS,
170
- TYPED_ARRAY_CONSTRUCTOR: TYPED_ARRAY_CONSTRUCTOR,
171
180
  TYPED_ARRAY_TAG: TYPED_ARRAY_TAG_REQUIRED && TYPED_ARRAY_TAG,
172
181
  aTypedArray: aTypedArray,
173
182
  aTypedArrayConstructor: aTypedArrayConstructor,
174
183
  exportTypedArrayMethod: exportTypedArrayMethod,
175
184
  exportTypedArrayStaticMethod: exportTypedArrayStaticMethod,
185
+ getTypedArrayConstructor: getTypedArrayConstructor,
176
186
  isView: isView,
177
187
  isTypedArray: isTypedArray,
178
188
  TypedArray: TypedArray,
@@ -12,8 +12,10 @@ module.exports = function (O, key, value, options) {
12
12
  if (simple) O[key] = value;
13
13
  else defineGlobalProperty(key, value);
14
14
  } else {
15
- if (!options.unsafe) delete O[key];
16
- else if (O[key]) simple = true;
15
+ try {
16
+ if (!options.unsafe) delete O[key];
17
+ else if (O[key]) simple = true;
18
+ } catch (error) { /* empty */ }
17
19
  if (simple) O[key] = value;
18
20
  else definePropertyModule.f(O, key, {
19
21
  value: value,
@@ -0,0 +1,8 @@
1
+ var classof = require('../internals/classof');
2
+ var uncurryThis = require('../internals/function-uncurry-this');
3
+
4
+ var slice = uncurryThis(''.slice);
5
+
6
+ module.exports = function (it) {
7
+ return slice(classof(it), 0, 3) === 'Big';
8
+ };
@@ -24,7 +24,8 @@ var makeBuiltIn = module.exports = function (value, name, options) {
24
24
  if (options && options.getter) name = 'get ' + name;
25
25
  if (options && options.setter) name = 'set ' + name;
26
26
  if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
27
- defineProperty(value, 'name', { value: name, configurable: true });
27
+ if (DESCRIPTORS) defineProperty(value, 'name', { value: name, configurable: true });
28
+ else value.name = name;
28
29
  }
29
30
  if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
30
31
  defineProperty(value, 'length', { value: options.arity });
@@ -12,6 +12,7 @@ module.exports = function () {
12
12
  if (that.multiline) result += 'm';
13
13
  if (that.dotAll) result += 's';
14
14
  if (that.unicode) result += 'u';
15
+ if (that.unicodeSets) result += 'v';
15
16
  if (that.sticky) result += 'y';
16
17
  return result;
17
18
  };
@@ -4,9 +4,9 @@ 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.23.0',
7
+ version: '3.23.3',
8
8
  mode: IS_PURE ? 'pure' : 'global',
9
9
  copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
10
- license: 'https://github.com/zloirock/core-js/blob/v3.23.0/LICENSE',
10
+ license: 'https://github.com/zloirock/core-js/blob/v3.23.3/LICENSE',
11
11
  source: 'https://github.com/zloirock/core-js'
12
12
  });
@@ -32,6 +32,7 @@ var inheritIfRequired = require('../internals/inherit-if-required');
32
32
 
33
33
  var getInternalState = InternalStateModule.get;
34
34
  var setInternalState = InternalStateModule.set;
35
+ var enforceInternalState = InternalStateModule.enforce;
35
36
  var nativeDefineProperty = definePropertyModule.f;
36
37
  var nativeGetOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
37
38
  var round = Math.round;
@@ -40,7 +41,6 @@ var ArrayBuffer = ArrayBufferModule.ArrayBuffer;
40
41
  var ArrayBufferPrototype = ArrayBuffer.prototype;
41
42
  var DataView = ArrayBufferModule.DataView;
42
43
  var NATIVE_ARRAY_BUFFER_VIEWS = ArrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS;
43
- var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
44
44
  var TYPED_ARRAY_TAG = ArrayBufferViewCore.TYPED_ARRAY_TAG;
45
45
  var TypedArray = ArrayBufferViewCore.TypedArray;
46
46
  var TypedArrayPrototype = ArrayBufferViewCore.TypedArrayPrototype;
@@ -217,7 +217,7 @@ if (DESCRIPTORS) {
217
217
  createNonEnumerableProperty(TypedArrayConstructorPrototype, 'constructor', TypedArrayConstructor);
218
218
  }
219
219
 
220
- createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_CONSTRUCTOR, TypedArrayConstructor);
220
+ enforceInternalState(TypedArrayConstructorPrototype).TypedArrayConstructor = TypedArrayConstructor;
221
221
 
222
222
  if (TYPED_ARRAY_TAG) {
223
223
  createNonEnumerableProperty(TypedArrayConstructorPrototype, TYPED_ARRAY_TAG, CONSTRUCTOR_NAME);
@@ -1,11 +1,11 @@
1
1
  var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
2
2
  var speciesConstructor = require('../internals/species-constructor');
3
3
 
4
- var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
5
4
  var aTypedArrayConstructor = ArrayBufferViewCore.aTypedArrayConstructor;
5
+ var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
6
6
 
7
7
  // a part of `TypedArraySpeciesCreate` abstract operation
8
8
  // https://tc39.es/ecma262/#typedarray-species-create
9
9
  module.exports = function (originalArray) {
10
- return aTypedArrayConstructor(speciesConstructor(originalArray, originalArray[TYPED_ARRAY_CONSTRUCTOR]));
10
+ return aTypedArrayConstructor(speciesConstructor(originalArray, getTypedArrayConstructor(originalArray)));
11
11
  };
@@ -1,18 +1,43 @@
1
1
  'use strict';
2
2
  var $ = require('../internals/export');
3
- var toIndexedObject = require('../internals/to-indexed-object');
4
- var arraySlice = require('../internals/array-slice');
5
- var arrayToSpliced = require('../internals/array-to-spliced');
6
3
  var addToUnscopables = require('../internals/add-to-unscopables');
4
+ var doesNotExceedSafeInteger = require('../internals/does-not-exceed-safe-integer');
5
+ var lengthOfArrayLike = require('../internals/length-of-array-like');
6
+ var toAbsoluteIndex = require('../internals/to-absolute-index');
7
+ var toIndexedObject = require('../internals/to-indexed-object');
8
+ var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
7
9
 
8
10
  var $Array = Array;
11
+ var max = Math.max;
12
+ var min = Math.min;
9
13
 
10
14
  // `Array.prototype.toSpliced` method
11
15
  // https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toSpliced
12
- $({ target: 'Array', proto: true, arity: 2 }, {
13
- // eslint-disable-next-line no-unused-vars -- required for .length
16
+ $({ target: 'Array', proto: true }, {
14
17
  toSpliced: function toSpliced(start, deleteCount /* , ...items */) {
15
- return arrayToSpliced(toIndexedObject(this), $Array, arraySlice(arguments));
18
+ var O = toIndexedObject(this);
19
+ var len = lengthOfArrayLike(O);
20
+ var actualStart = toAbsoluteIndex(start, len);
21
+ var argumentsLength = arguments.length;
22
+ var k = 0;
23
+ var insertCount, actualDeleteCount, newLen, A;
24
+ if (argumentsLength === 0) {
25
+ insertCount = actualDeleteCount = 0;
26
+ } else if (argumentsLength === 1) {
27
+ insertCount = 0;
28
+ actualDeleteCount = len - actualStart;
29
+ } else {
30
+ insertCount = argumentsLength - 2;
31
+ actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
32
+ }
33
+ newLen = doesNotExceedSafeInteger(len + insertCount - actualDeleteCount);
34
+ A = $Array(newLen);
35
+
36
+ for (; k < actualStart; k++) A[k] = O[k];
37
+ for (; k < actualStart + insertCount; k++) A[k] = arguments[k - actualStart + 2];
38
+ for (; k < newLen; k++) A[k] = O[k + actualDeleteCount - insertCount];
39
+
40
+ return A;
16
41
  }
17
42
  });
18
43
 
@@ -2,6 +2,6 @@ var $ = require('../internals/export');
2
2
 
3
3
  // `Math.DEG_PER_RAD` constant
4
4
  // https://rwaldron.github.io/proposal-math-extensions/
5
- $({ target: 'Math', stat: true, nonConfigurable: true, nonWritable: true, forced: true }, {
5
+ $({ target: 'Math', stat: true, nonConfigurable: true, nonWritable: true }, {
6
6
  DEG_PER_RAD: Math.PI / 180
7
7
  });
@@ -2,6 +2,6 @@ var $ = require('../internals/export');
2
2
 
3
3
  // `Math.RAD_PER_DEG` constant
4
4
  // https://rwaldron.github.io/proposal-math-extensions/
5
- $({ target: 'Math', stat: true, nonConfigurable: true, nonWritable: true, forced: true }, {
5
+ $({ target: 'Math', stat: true, nonConfigurable: true, nonWritable: true }, {
6
6
  RAD_PER_DEG: 180 / Math.PI
7
7
  });
@@ -4,10 +4,10 @@ var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
4
4
 
5
5
  var aTypedArray = ArrayBufferViewCore.aTypedArray;
6
6
  var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
7
- var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
7
+ var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
8
8
 
9
9
  // `%TypedArray%.prototype.toReversed` method
10
10
  // https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toReversed
11
11
  exportTypedArrayMethod('toReversed', function toReversed() {
12
- return arrayToReversed(aTypedArray(this), this[TYPED_ARRAY_CONSTRUCTOR]);
12
+ return arrayToReversed(aTypedArray(this), getTypedArrayConstructor(this));
13
13
  });
@@ -5,8 +5,8 @@ var aCallable = require('../internals/a-callable');
5
5
  var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
6
6
 
7
7
  var aTypedArray = ArrayBufferViewCore.aTypedArray;
8
+ var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
8
9
  var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
9
- var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
10
10
  var sort = uncurryThis(ArrayBufferViewCore.TypedArrayPrototype.sort);
11
11
 
12
12
  // `%TypedArray%.prototype.toSorted` method
@@ -14,6 +14,6 @@ var sort = uncurryThis(ArrayBufferViewCore.TypedArrayPrototype.sort);
14
14
  exportTypedArrayMethod('toSorted', function toSorted(compareFn) {
15
15
  if (compareFn !== undefined) aCallable(compareFn);
16
16
  var O = aTypedArray(this);
17
- var A = arrayFromConstructorAndList(O[TYPED_ARRAY_CONSTRUCTOR], O);
17
+ var A = arrayFromConstructorAndList(getTypedArrayConstructor(O), O);
18
18
  return sort(A, compareFn);
19
19
  });
@@ -1,15 +1,62 @@
1
1
  'use strict';
2
2
  var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
3
- var arraySlice = require('../internals/array-slice');
4
- var arrayToSpliced = require('../internals/array-to-spliced');
3
+ var lengthOfArrayLike = require('../internals/length-of-array-like');
4
+ var toAbsoluteIndex = require('../internals/to-absolute-index');
5
+ var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
6
+ var fails = require('../internals/fails');
5
7
 
6
8
  var aTypedArray = ArrayBufferViewCore.aTypedArray;
9
+ var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
7
10
  var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
8
- var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
11
+ var max = Math.max;
12
+ var min = Math.min;
13
+
14
+ // some early implementations, like WebKit, does not follow the final semantic
15
+ var PROPER_ORDER = !fails(function () {
16
+ // eslint-disable-next-line es-x/no-typed-arrays -- required for testing
17
+ var array = new Int8Array([1]);
18
+
19
+ var spliced = array.toSpliced(1, 0, {
20
+ valueOf: function () {
21
+ array[0] = 2;
22
+ return 3;
23
+ }
24
+ });
25
+
26
+ return spliced[0] !== 2 || spliced[1] !== 3;
27
+ });
9
28
 
10
29
  // `%TypedArray%.prototype.toSpliced` method
11
30
  // https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toSpliced
12
- // eslint-disable-next-line no-unused-vars -- required for .length
13
31
  exportTypedArrayMethod('toSpliced', function toSpliced(start, deleteCount /* , ...items */) {
14
- return arrayToSpliced(aTypedArray(this), this[TYPED_ARRAY_CONSTRUCTOR], arraySlice(arguments));
15
- }, { arity: 2 });
32
+ var O = aTypedArray(this);
33
+ var C = getTypedArrayConstructor(O);
34
+ var len = lengthOfArrayLike(O);
35
+ var actualStart = toAbsoluteIndex(start, len);
36
+ var argumentsLength = arguments.length;
37
+ var k = 0;
38
+ var insertCount, actualDeleteCount, convertedItems, newLen, A;
39
+ if (argumentsLength === 0) {
40
+ insertCount = actualDeleteCount = 0;
41
+ } else if (argumentsLength === 1) {
42
+ insertCount = 0;
43
+ actualDeleteCount = len - actualStart;
44
+ } else {
45
+ actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
46
+ insertCount = argumentsLength - 2;
47
+ if (insertCount) {
48
+ convertedItems = new C(insertCount);
49
+ for (var i = 2; i < argumentsLength; i++) {
50
+ convertedItems[i - 2] = arguments[i];
51
+ }
52
+ }
53
+ }
54
+ newLen = len + insertCount - actualDeleteCount;
55
+ A = new C(newLen);
56
+
57
+ for (; k < actualStart; k++) A[k] = O[k];
58
+ for (; k < actualStart + insertCount; k++) A[k] = convertedItems[k - actualStart];
59
+ for (; k < newLen; k++) A[k] = O[k + actualDeleteCount - insertCount];
60
+
61
+ return A;
62
+ }, !PROPER_ORDER);
@@ -1,15 +1,13 @@
1
1
  'use strict';
2
2
  var arrayWith = require('../internals/array-with');
3
3
  var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
4
+ var isBigIntArray = require('../internals/is-big-int-array');
4
5
  var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
5
6
  var toBigInt = require('../internals/to-big-int');
6
- var classof = require('../internals/classof');
7
- var uncurryThis = require('../internals/function-uncurry-this');
8
7
 
9
8
  var aTypedArray = ArrayBufferViewCore.aTypedArray;
9
+ var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
10
10
  var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
11
- var TYPED_ARRAY_CONSTRUCTOR = ArrayBufferViewCore.TYPED_ARRAY_CONSTRUCTOR;
12
- var slice = uncurryThis(''.slice);
13
11
 
14
12
  var PROPER_ORDER = !!function () {
15
13
  try {
@@ -25,8 +23,8 @@ var PROPER_ORDER = !!function () {
25
23
  // `%TypedArray%.prototype.with` method
26
24
  // https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.with
27
25
  exportTypedArrayMethod('with', { 'with': function (index, value) {
28
- aTypedArray(this);
26
+ var O = aTypedArray(this);
29
27
  var relativeIndex = toIntegerOrInfinity(index);
30
- var actualValue = slice(classof(this), 0, 3) === 'Big' ? toBigInt(value) : +value;
31
- return arrayWith(this, this[TYPED_ARRAY_CONSTRUCTOR], relativeIndex, actualValue);
28
+ var actualValue = isBigIntArray(O) ? toBigInt(value) : +value;
29
+ return arrayWith(O, getTypedArrayConstructor(O), relativeIndex, actualValue);
32
30
  } }['with'], !PROPER_ORDER);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "core-js",
3
3
  "description": "Standard library",
4
- "version": "3.23.0",
4
+ "version": "3.23.3",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/zloirock/core-js.git"
@@ -1,36 +0,0 @@
1
- var lengthOfArrayLike = require('../internals/length-of-array-like');
2
- var doesNotExceedSafeInteger = require('../internals/does-not-exceed-safe-integer');
3
- var toAbsoluteIndex = require('../internals/to-absolute-index');
4
- var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
5
-
6
- var max = Math.max;
7
- var min = Math.min;
8
-
9
- // https://tc39.es/proposal-change-array-by-copy/#sec-array.prototype.toSpliced
10
- // https://tc39.es/proposal-change-array-by-copy/#sec-%typedarray%.prototype.toSpliced
11
- module.exports = function (O, C, args) {
12
- var start = args[0];
13
- var deleteCount = args[1];
14
- var len = lengthOfArrayLike(O);
15
- var actualStart = toAbsoluteIndex(start, len);
16
- var argumentsLength = args.length;
17
- var k = 0;
18
- var insertCount, actualDeleteCount, newLen, A;
19
- if (argumentsLength === 0) {
20
- insertCount = actualDeleteCount = 0;
21
- } else if (argumentsLength === 1) {
22
- insertCount = 0;
23
- actualDeleteCount = len - actualStart;
24
- } else {
25
- insertCount = argumentsLength - 2;
26
- actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart);
27
- }
28
- newLen = doesNotExceedSafeInteger(len + insertCount - actualDeleteCount);
29
- A = new C(newLen);
30
-
31
- for (; k < actualStart; k++) A[k] = O[k];
32
- for (; k < actualStart + insertCount; k++) A[k] = args[k - actualStart + 2];
33
- for (; k < newLen; k++) A[k] = O[k + actualDeleteCount - insertCount];
34
-
35
- return A;
36
- };