core-js 3.38.0 → 3.38.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.
@@ -205,7 +205,7 @@ if (!NATIVE_ARRAY_BUFFER) {
205
205
  });
206
206
  } else {
207
207
  var INCORRECT_ARRAY_BUFFER_NAME = PROPER_FUNCTION_NAME && NativeArrayBuffer.name !== ARRAY_BUFFER;
208
- /* eslint-disable no-new -- required for testing */
208
+ /* eslint-disable no-new, sonar/inconsistent-function-call -- required for testing */
209
209
  if (!fails(function () {
210
210
  NativeArrayBuffer(1);
211
211
  }) || !fails(function () {
@@ -216,7 +216,7 @@ if (!NATIVE_ARRAY_BUFFER) {
216
216
  new NativeArrayBuffer(NaN);
217
217
  return NativeArrayBuffer.length !== 1 || INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME;
218
218
  })) {
219
- /* eslint-enable no-new -- required for testing */
219
+ /* eslint-enable no-new, sonar/inconsistent-function-call -- required for testing */
220
220
  $ArrayBuffer = function ArrayBuffer(length) {
221
221
  anInstance(this, ArrayBufferPrototype);
222
222
  return inheritIfRequired(new NativeArrayBuffer(toIndex(length)), this, $ArrayBuffer);
@@ -23,8 +23,8 @@ module.exports = {
23
23
  setInternalState(that, {
24
24
  type: CONSTRUCTOR_NAME,
25
25
  index: create(null),
26
- first: undefined,
27
- last: undefined,
26
+ first: null,
27
+ last: null,
28
28
  size: 0
29
29
  });
30
30
  if (!DESCRIPTORS) that.size = 0;
@@ -49,7 +49,7 @@ module.exports = {
49
49
  key: key,
50
50
  value: value,
51
51
  previous: previous = state.last,
52
- next: undefined,
52
+ next: null,
53
53
  removed: false
54
54
  };
55
55
  if (!state.first) state.first = entry;
@@ -83,10 +83,10 @@ module.exports = {
83
83
  var entry = state.first;
84
84
  while (entry) {
85
85
  entry.removed = true;
86
- if (entry.previous) entry.previous = entry.previous.next = undefined;
86
+ if (entry.previous) entry.previous = entry.previous.next = null;
87
87
  entry = entry.next;
88
88
  }
89
- state.first = state.last = undefined;
89
+ state.first = state.last = null;
90
90
  state.index = create(null);
91
91
  if (DESCRIPTORS) state.size = 0;
92
92
  else that.size = 0;
@@ -178,7 +178,7 @@ module.exports = {
178
178
  target: iterated,
179
179
  state: getInternalCollectionState(iterated),
180
180
  kind: kind,
181
- last: undefined
181
+ last: null
182
182
  });
183
183
  }, function () {
184
184
  var state = getInternalIteratorState(this);
@@ -189,7 +189,7 @@ module.exports = {
189
189
  // get next entry
190
190
  if (!state.target || !(state.last = entry = entry ? entry.next : state.state.first)) {
191
191
  // or finish the iteration
192
- state.target = undefined;
192
+ state.target = null;
193
193
  return createIterResultObject(undefined, true);
194
194
  }
195
195
  // return step by kind
@@ -62,7 +62,7 @@ module.exports = {
62
62
  setInternalState(that, {
63
63
  type: CONSTRUCTOR_NAME,
64
64
  id: id++,
65
- frozen: undefined
65
+ frozen: null
66
66
  });
67
67
  if (!isNullOrUndefined(iterable)) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
68
68
  });
@@ -110,7 +110,7 @@ module.exports = {
110
110
  if (isObject(key)) {
111
111
  var data = getWeakData(key);
112
112
  if (data === true) return uncaughtFrozenStore(state).get(key);
113
- return data ? data[state.id] : undefined;
113
+ if (data) return data[state.id];
114
114
  }
115
115
  },
116
116
  // `WeakMap.prototype.set(key, value)` method
@@ -1,4 +1,6 @@
1
1
  'use strict';
2
+ /* eslint-disable no-undef, no-useless-call, sonar/no-reference-error -- required for testing */
3
+ /* eslint-disable es/no-legacy-object-prototype-accessor-methods -- required for testing */
2
4
  var IS_PURE = require('../internals/is-pure');
3
5
  var globalThis = require('../internals/global-this');
4
6
  var fails = require('../internals/fails');
@@ -11,7 +13,6 @@ module.exports = IS_PURE || !fails(function () {
11
13
  if (WEBKIT && WEBKIT < 535) return;
12
14
  var key = Math.random();
13
15
  // In FF throws only define methods
14
- // eslint-disable-next-line no-undef, no-useless-call, es/no-legacy-object-prototype-accessor-methods -- required for testing
15
16
  __defineSetter__.call(null, key, function () { /* empty */ });
16
17
  delete globalThis[key];
17
18
  });
@@ -7,9 +7,9 @@ var SHARED = '__core-js_shared__';
7
7
  var store = module.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
8
8
 
9
9
  (store.versions || (store.versions = [])).push({
10
- version: '3.38.0',
10
+ version: '3.38.1',
11
11
  mode: IS_PURE ? 'pure' : 'global',
12
12
  copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
13
- license: 'https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE',
13
+ license: 'https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE',
14
14
  source: 'https://github.com/zloirock/core-js'
15
15
  });
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
- /* eslint-disable no-new -- required for testing */
2
+ /* eslint-disable no-new, sonar/inconsistent-function-call -- required for testing */
3
3
  var globalThis = require('../internals/global-this');
4
4
  var fails = require('../internals/fails');
5
5
  var checkCorrectnessOfIteration = require('../internals/check-correctness-of-iteration');
@@ -37,7 +37,7 @@ module.exports = defineIterator(Array, 'Array', function (iterated, kind) {
37
37
  var target = state.target;
38
38
  var index = state.index++;
39
39
  if (!target || index >= target.length) {
40
- state.target = undefined;
40
+ state.target = null;
41
41
  return createIterResultObject(undefined, true);
42
42
  }
43
43
  switch (state.kind) {
@@ -220,7 +220,7 @@ if (FORCED_PROMISE_CONSTRUCTOR) {
220
220
  reactions: new Queue(),
221
221
  rejection: false,
222
222
  state: PENDING,
223
- value: undefined
223
+ value: null
224
224
  });
225
225
  };
226
226
 
@@ -46,6 +46,7 @@ var BASE_FORCED = DESCRIPTORS &&
46
46
  (!CORRECT_NEW || MISSED_STICKY || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG || fails(function () {
47
47
  re2[MATCH] = false;
48
48
  // RegExp constructor can alter flags and IsRegExp works correct with @@match
49
+ // eslint-disable-next-line sonar/inconsistent-function-call -- required for testing
49
50
  return NativeRegExp(re1) !== re1 || NativeRegExp(re2) === re2 || String(NativeRegExp(re1, 'i')) !== '/a/i';
50
51
  }));
51
52
 
@@ -24,6 +24,7 @@ if (DESCRIPTORS && isCallable(NativeSymbol) && (!('description' in SymbolPrototy
24
24
  var SymbolWrapper = function Symbol() {
25
25
  var description = arguments.length < 1 || arguments[0] === undefined ? undefined : toString(arguments[0]);
26
26
  var result = isPrototypeOf(SymbolPrototype, this)
27
+ // eslint-disable-next-line sonar/inconsistent-function-call -- ok
27
28
  ? new NativeSymbol(description)
28
29
  // in Edge 13, String(Symbol(undefined)) === 'Symbol(undefined)'
29
30
  : description === undefined ? NativeSymbol() : NativeSymbol(description);
@@ -72,14 +72,14 @@ defineBuiltIns(AsyncDisposableStackPrototype, {
72
72
  var loop = function () {
73
73
  if (i) {
74
74
  var disposeMethod = stack[--i];
75
- stack[i] = undefined;
75
+ stack[i] = null;
76
76
  try {
77
77
  Promise.resolve(disposeMethod()).then(loop, handleError);
78
78
  } catch (error) {
79
79
  handleError(error);
80
80
  }
81
81
  } else {
82
- internalState.stack = undefined;
82
+ internalState.stack = null;
83
83
  thrown ? reject(suppressed) : resolve(undefined);
84
84
  }
85
85
  };
@@ -56,7 +56,7 @@ defineBuiltIns(DisposableStackPrototype, {
56
56
  var suppressed;
57
57
  while (i) {
58
58
  var disposeMethod = stack[--i];
59
- stack[i] = undefined;
59
+ stack[i] = null;
60
60
  try {
61
61
  disposeMethod();
62
62
  } catch (errorResult) {
@@ -68,7 +68,7 @@ defineBuiltIns(DisposableStackPrototype, {
68
68
  }
69
69
  }
70
70
  }
71
- internalState.stack = undefined;
71
+ internalState.stack = null;
72
72
  if (thrown) throw suppressed;
73
73
  },
74
74
  use: function use(value) {
@@ -30,8 +30,8 @@ var getSubscriptionObserverInternalState = getterFor(SUBSCRIPTION_OBSERVER);
30
30
 
31
31
  var SubscriptionState = function (observer) {
32
32
  this.observer = anObject(observer);
33
- this.cleanup = undefined;
34
- this.subscriptionObserver = undefined;
33
+ this.cleanup = null;
34
+ this.subscriptionObserver = null;
35
35
  };
36
36
 
37
37
  SubscriptionState.prototype = {
@@ -39,7 +39,7 @@ SubscriptionState.prototype = {
39
39
  clean: function () {
40
40
  var cleanup = this.cleanup;
41
41
  if (cleanup) {
42
- this.cleanup = undefined;
42
+ this.cleanup = null;
43
43
  try {
44
44
  cleanup();
45
45
  } catch (error) {
@@ -53,10 +53,10 @@ SubscriptionState.prototype = {
53
53
  var subscriptionObserver = this.subscriptionObserver;
54
54
  subscription.closed = true;
55
55
  if (subscriptionObserver) subscriptionObserver.closed = true;
56
- } this.observer = undefined;
56
+ } this.observer = null;
57
57
  },
58
58
  isClosed: function () {
59
- return this.observer === undefined;
59
+ return this.observer === null;
60
60
  }
61
61
  };
62
62
 
@@ -86,6 +86,7 @@ var dedentStringsArray = function (template) {
86
86
  lines[lines.length - 2] = '';
87
87
  lines[lines.length - 1] = '';
88
88
  }
89
+ // eslint-disable-next-line sonar/no-redundant-assignments -- false positive, https://github.com/SonarSource/SonarJS/issues/4767
89
90
  for (var j = 2; j < lines.length; j += 2) {
90
91
  var text = lines[j];
91
92
  var lineContainsTemplateExpression = j + 1 === lines.length && !lastSplit;
@@ -1,9 +1,11 @@
1
1
  'use strict';
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
+ require('../modules/es.string.from-code-point');
4
5
  var $ = require('../internals/export');
5
6
  var globalThis = require('../internals/global-this');
6
7
  var safeGetBuiltIn = require('../internals/safe-get-built-in');
8
+ var getBuiltIn = require('../internals/get-built-in');
7
9
  var call = require('../internals/function-call');
8
10
  var uncurryThis = require('../internals/function-uncurry-this');
9
11
  var DESCRIPTORS = require('../internals/descriptors');
@@ -43,10 +45,11 @@ var NativeRequest = safeGetBuiltIn('Request');
43
45
  var Headers = safeGetBuiltIn('Headers');
44
46
  var RequestPrototype = NativeRequest && NativeRequest.prototype;
45
47
  var HeadersPrototype = Headers && Headers.prototype;
46
- var RegExp = globalThis.RegExp;
47
48
  var TypeError = globalThis.TypeError;
48
- var decodeURIComponent = globalThis.decodeURIComponent;
49
49
  var encodeURIComponent = globalThis.encodeURIComponent;
50
+ var fromCharCode = String.fromCharCode;
51
+ var fromCodePoint = getBuiltIn('String', 'fromCodePoint');
52
+ var $parseInt = parseInt;
50
53
  var charAt = uncurryThis(''.charAt);
51
54
  var join = uncurryThis([].join);
52
55
  var push = uncurryThis([].push);
@@ -55,33 +58,125 @@ var shift = uncurryThis([].shift);
55
58
  var splice = uncurryThis([].splice);
56
59
  var split = uncurryThis(''.split);
57
60
  var stringSlice = uncurryThis(''.slice);
61
+ var exec = uncurryThis(/./.exec);
58
62
 
59
63
  var plus = /\+/g;
60
- var sequences = Array(4);
64
+ var FALLBACK_REPLACER = '\uFFFD';
65
+ var VALID_HEX = /^[0-9a-f]+$/i;
61
66
 
62
- var percentSequence = function (bytes) {
63
- return sequences[bytes - 1] || (sequences[bytes - 1] = RegExp('((?:%[\\da-f]{2}){' + bytes + '})', 'gi'));
67
+ var parseHexOctet = function (string, start) {
68
+ var substr = stringSlice(string, start, start + 2);
69
+ if (!exec(VALID_HEX, substr)) return NaN;
70
+
71
+ return $parseInt(substr, 16);
72
+ };
73
+
74
+ var getLeadingOnes = function (octet) {
75
+ var count = 0;
76
+ for (var mask = 0x80; mask > 0 && (octet & mask) !== 0; mask >>= 1) {
77
+ count++;
78
+ }
79
+ return count;
64
80
  };
65
81
 
66
- var percentDecode = function (sequence) {
67
- try {
68
- return decodeURIComponent(sequence);
69
- } catch (error) {
70
- return sequence;
82
+ var utf8Decode = function (octets) {
83
+ var codePoint = null;
84
+
85
+ switch (octets.length) {
86
+ case 1:
87
+ codePoint = octets[0];
88
+ break;
89
+ case 2:
90
+ codePoint = (octets[0] & 0x1F) << 6 | (octets[1] & 0x3F);
91
+ break;
92
+ case 3:
93
+ codePoint = (octets[0] & 0x0F) << 12 | (octets[1] & 0x3F) << 6 | (octets[2] & 0x3F);
94
+ break;
95
+ case 4:
96
+ codePoint = (octets[0] & 0x07) << 18 | (octets[1] & 0x3F) << 12 | (octets[2] & 0x3F) << 6 | (octets[3] & 0x3F);
97
+ break;
71
98
  }
99
+
100
+ return codePoint > 0x10FFFF ? null : codePoint;
72
101
  };
73
102
 
74
- var deserialize = function (it) {
75
- var result = replace(it, plus, ' ');
76
- var bytes = 4;
77
- try {
78
- return decodeURIComponent(result);
79
- } catch (error) {
80
- while (bytes) {
81
- result = replace(result, percentSequence(bytes--), percentDecode);
103
+ var decode = function (input) {
104
+ input = replace(input, plus, ' ');
105
+ var length = input.length;
106
+ var result = '';
107
+ var i = 0;
108
+
109
+ while (i < length) {
110
+ var decodedChar = charAt(input, i);
111
+
112
+ if (decodedChar === '%') {
113
+ if (charAt(input, i + 1) === '%' || i + 3 > length) {
114
+ result += '%';
115
+ i++;
116
+ continue;
117
+ }
118
+
119
+ var octet = parseHexOctet(input, i + 1);
120
+
121
+ // eslint-disable-next-line no-self-compare -- NaN check
122
+ if (octet !== octet) {
123
+ result += decodedChar;
124
+ i++;
125
+ continue;
126
+ }
127
+
128
+ i += 2;
129
+ var byteSequenceLength = getLeadingOnes(octet);
130
+
131
+ if (byteSequenceLength === 0) {
132
+ decodedChar = fromCharCode(octet);
133
+ } else {
134
+ if (byteSequenceLength === 1 || byteSequenceLength > 4) {
135
+ result += FALLBACK_REPLACER;
136
+ i++;
137
+ continue;
138
+ }
139
+
140
+ var octets = [octet];
141
+ var sequenceIndex = 1;
142
+
143
+ while (sequenceIndex < byteSequenceLength) {
144
+ i++;
145
+ if (i + 3 > length || charAt(input, i) !== '%') break;
146
+
147
+ var nextByte = parseHexOctet(input, i + 1);
148
+
149
+ // eslint-disable-next-line no-self-compare -- NaN check
150
+ if (nextByte !== nextByte) {
151
+ i += 3;
152
+ break;
153
+ }
154
+ if (nextByte > 191 || nextByte < 128) break;
155
+
156
+ push(octets, nextByte);
157
+ i += 2;
158
+ sequenceIndex++;
159
+ }
160
+
161
+ if (octets.length !== byteSequenceLength) {
162
+ result += FALLBACK_REPLACER;
163
+ continue;
164
+ }
165
+
166
+ var codePoint = utf8Decode(octets);
167
+ if (codePoint === null) {
168
+ result += FALLBACK_REPLACER;
169
+ } else {
170
+ decodedChar = fromCodePoint(codePoint);
171
+ }
172
+ }
82
173
  }
83
- return result;
174
+
175
+ result += decodedChar;
176
+ i++;
84
177
  }
178
+
179
+ return result;
85
180
  };
86
181
 
87
182
  var find = /[!'()~]|%20/g;
@@ -115,7 +210,7 @@ var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params
115
210
  var target = state.target;
116
211
  var index = state.index++;
117
212
  if (!target || index >= target.length) {
118
- state.target = undefined;
213
+ state.target = null;
119
214
  return createIterResultObject(undefined, true);
120
215
  }
121
216
  var entry = target[index];
@@ -174,8 +269,8 @@ URLSearchParamsState.prototype = {
174
269
  if (attribute.length) {
175
270
  entry = split(attribute, '=');
176
271
  push(entries, {
177
- key: deserialize(shift(entry)),
178
- value: deserialize(join(entry, '='))
272
+ key: decode(shift(entry)),
273
+ value: decode(join(entry, '='))
179
274
  });
180
275
  }
181
276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-js",
3
- "version": "3.38.0",
3
+ "version": "3.38.1",
4
4
  "type": "commonjs",
5
5
  "description": "Standard library",
6
6
  "keywords": [
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "repository": {
55
55
  "type": "git",
56
- "url": "https://github.com/zloirock/core-js.git",
56
+ "url": "git+https://github.com/zloirock/core-js.git",
57
57
  "directory": "packages/core-js"
58
58
  },
59
59
  "funding": {