core-js-pure 3.45.0 → 3.46.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.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2025 Denis Pushkarev
1
+ Copyright (c) 2014-2025 Denis Pushkarev, 2025 CoreJS Company
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  **I highly recommend reading this: [So, what's next?](https://github.com/zloirock/core-js/blob/master/docs/2023-02-14-so-whats-next.md)**
10
10
  ---
11
11
 
12
- > Modular standard library for JavaScript. Includes polyfills for [ECMAScript up to 2023](https://github.com/zloirock/core-js#ecmascript): [promises](https://github.com/zloirock/core-js#ecmascript-promise), [symbols](https://github.com/zloirock/core-js#ecmascript-symbol), [collections](https://github.com/zloirock/core-js#ecmascript-collections), iterators, [typed arrays](https://github.com/zloirock/core-js#ecmascript-typed-arrays), many other features, [ECMAScript proposals](https://github.com/zloirock/core-js#ecmascript-proposals), [some cross-platform WHATWG / W3C features and proposals](#web-standards) like [`URL`](https://github.com/zloirock/core-js#url-and-urlsearchparams). You can load only required features or use it without global namespace pollution.
12
+ > Modular standard library for JavaScript. Includes polyfills for [ECMAScript up to 2025](https://github.com/zloirock/core-js#ecmascript): [promises](https://github.com/zloirock/core-js#ecmascript-promise), [symbols](https://github.com/zloirock/core-js#ecmascript-symbol), [collections](https://github.com/zloirock/core-js#ecmascript-collections), iterators, [typed arrays](https://github.com/zloirock/core-js#ecmascript-typed-arrays), many other features, [ECMAScript proposals](https://github.com/zloirock/core-js#ecmascript-proposals), [some cross-platform WHATWG / W3C features and proposals](#web-standards) like [`URL`](https://github.com/zloirock/core-js#url-and-urlsearchparams). You can load only required features or use it without global namespace pollution.
13
13
 
14
14
  ## Raising funds
15
15
 
@@ -25,17 +25,17 @@
25
25
 
26
26
  ---
27
27
 
28
- [*Example of usage*](https://tinyurl.com/2mknex43):
28
+ [*Example of usage*](https://tinyurl.com/28zqjbun):
29
29
  ```js
30
30
  import 'core-js/actual';
31
31
 
32
- Promise.resolve(42).then(it => console.log(it)); // => 42
32
+ Promise.try(() => 42).then(it => console.log(it)); // => 42
33
33
 
34
34
  Array.from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5]
35
35
 
36
36
  [1, 2].flatMap(it => [it, it]); // => [1, 1, 2, 2]
37
37
 
38
- (function * (i) { while (true) yield i++; })(1)
38
+ Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3))
39
39
  .drop(1).take(5)
40
40
  .filter(it => it % 2)
41
41
  .map(it => it ** 2)
@@ -53,13 +53,13 @@ import 'core-js/actual/array/from';
53
53
  import 'core-js/actual/array/flat-map';
54
54
  import 'core-js/actual/structured-clone';
55
55
 
56
- Promise.resolve(42).then(it => console.log(it)); // => 42
56
+ Promise.try(() => 42).then(it => console.log(it)); // => 42
57
57
 
58
58
  Array.from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5]
59
59
 
60
60
  [1, 2].flatMap(it => [it, it]); // => [1, 1, 2, 2]
61
61
 
62
- (function * (i) { while (true) yield i++; })(1)
62
+ Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3))
63
63
  .drop(1).take(5)
64
64
  .filter(it => it % 2)
65
65
  .map(it => it ** 2)
@@ -77,13 +77,13 @@ import from from 'core-js-pure/actual/array/from';
77
77
  import flatMap from 'core-js-pure/actual/array/flat-map';
78
78
  import structuredClone from 'core-js-pure/actual/structured-clone';
79
79
 
80
- Promise.resolve(42).then(it => console.log(it)); // => 42
80
+ Promise.try(() => 42).then(it => console.log(it)); // => 42
81
81
 
82
82
  from(new Set([1, 2, 3]).union(new Set([3, 4, 5]))); // => [1, 2, 3, 4, 5]
83
83
 
84
84
  flatMap([1, 2], it => [it, it]); // => [1, 1, 2, 2]
85
85
 
86
- Iterator.from(function * (i) { while (true) yield i++; }(1))
86
+ Iterator.concat([1, 2], function * (i) { while (true) yield i++; }(3))
87
87
  .drop(1).take(5)
88
88
  .filter(it => it % 2)
89
89
  .map(it => it ** 2)
@@ -8,20 +8,22 @@ var iteratorClose = require('../internals/iterator-close');
8
8
  var uncurryThis = require('../internals/function-uncurry-this');
9
9
 
10
10
  var $RangeError = RangeError;
11
+ var $TypeError = TypeError;
11
12
  var push = uncurryThis([].push);
12
13
  var slice = uncurryThis([].slice);
14
+ var ALLOW_PARTIAL = 'allow-partial';
13
15
 
14
16
  var IteratorProxy = createIteratorProxy(function () {
15
17
  var iterator = this.iterator;
16
18
  var next = this.next;
17
19
  var buffer = this.buffer;
18
20
  var windowSize = this.windowSize;
19
- var sliding = this.sliding;
21
+ var allowPartial = this.allowPartial;
20
22
  var result, done;
21
23
  while (true) {
22
24
  result = anObject(call(next, iterator));
23
25
  done = this.done = !!result.done;
24
- if (sliding && done && buffer.length && buffer.length < windowSize) return createIterResultObject(buffer, false);
26
+ if (allowPartial && done && buffer.length && buffer.length < windowSize) return createIterResultObject(buffer, false);
25
27
  if (done) return createIterResultObject(undefined, true);
26
28
 
27
29
  if (buffer.length === windowSize) this.buffer = buffer = slice(buffer, 1);
@@ -30,16 +32,19 @@ var IteratorProxy = createIteratorProxy(function () {
30
32
  }
31
33
  }, false, true);
32
34
 
33
- // `Iterator.prototype.sliding` and `Iterator.prototype.windows` methods
35
+ // `Iterator.prototype.windows` and obsolete `Iterator.prototype.sliding` methods
34
36
  // https://github.com/tc39/proposal-iterator-chunking
35
- module.exports = function (O, windowSize, sliding) {
37
+ module.exports = function (O, windowSize, undersized) {
36
38
  anObject(O);
37
39
  if (typeof windowSize != 'number' || !windowSize || windowSize >>> 0 !== windowSize) {
38
- return iteratorClose(O, 'throw', new $RangeError('windowSize must be integer in [1, 2^32-1]'));
40
+ return iteratorClose(O, 'throw', new $RangeError('`windowSize` must be integer in [1, 2^32-1]'));
41
+ }
42
+ if (undersized !== undefined && undersized !== 'only-full' && undersized !== ALLOW_PARTIAL) {
43
+ return iteratorClose(O, 'throw', new $TypeError('Incorrect `undersized` argument'));
39
44
  }
40
45
  return new IteratorProxy(getIteratorDirect(O), {
41
46
  windowSize: windowSize,
42
47
  buffer: [],
43
- sliding: sliding
48
+ allowPartial: undersized === ALLOW_PARTIAL
44
49
  });
45
50
  };
@@ -28,7 +28,7 @@ var IteratorProxy = createIteratorProxy(function () {
28
28
  for (var i = 0; i < iterCount; i++) {
29
29
  var iter = iters[i];
30
30
  if (iter === null) {
31
- push(results, padding[i]);
31
+ result = padding[i];
32
32
  } else {
33
33
  try {
34
34
  result = call(iter.next, iter.iterator);
@@ -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.45.0',
10
+ version: '3.46.0',
11
11
  mode: IS_PURE ? 'pure' : 'global',
12
- copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)',
13
- license: 'https://github.com/zloirock/core-js/blob/v3.45.0/LICENSE',
12
+ copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru), 2025 CoreJS Company (core-js.io)',
13
+ license: 'https://github.com/zloirock/core-js/blob/v3.46.0/LICENSE',
14
14
  source: 'https://github.com/zloirock/core-js'
15
15
  });
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
  var $ = require('../internals/export');
3
+ var createProperty = require('../internals/create-property');
3
4
  var getBuiltIn = require('../internals/get-built-in');
4
5
  var uncurryThis = require('../internals/function-uncurry-this');
5
6
  var aCallable = require('../internals/a-callable');
@@ -33,7 +34,7 @@ $({ target: 'Object', stat: true, forced: DOES_NOT_WORK_WITH_PRIMITIVES }, {
33
34
  // in some IE versions, `hasOwnProperty` returns incorrect result on integer keys
34
35
  // but since it's a `null` prototype object, we can safely use `in`
35
36
  if (key in obj) push(obj[key], value);
36
- else obj[key] = [value];
37
+ else createProperty(obj, key, [value]);
37
38
  });
38
39
  return obj;
39
40
  }
@@ -6,6 +6,6 @@ var iteratorWindow = require('../internals/iterator-window');
6
6
  // https://github.com/tc39/proposal-iterator-chunking
7
7
  $({ target: 'Iterator', proto: true, real: true, forced: true }, {
8
8
  sliding: function sliding(windowSize) {
9
- return iteratorWindow(this, windowSize, true);
9
+ return iteratorWindow(this, windowSize, 'allow-partial');
10
10
  }
11
11
  });
@@ -5,7 +5,7 @@ var iteratorWindow = require('../internals/iterator-window');
5
5
  // `Iterator.prototype.windows` method
6
6
  // https://github.com/tc39/proposal-iterator-chunking
7
7
  $({ target: 'Iterator', proto: true, real: true, forced: true }, {
8
- windows: function windows(windowSize) {
9
- return iteratorWindow(this, windowSize, false);
8
+ windows: function windows(windowSize /* , undersized */) {
9
+ return iteratorWindow(this, windowSize, arguments.length < 2 ? undefined : arguments[1]);
10
10
  }
11
11
  });
@@ -2,6 +2,7 @@
2
2
  var $ = require('../internals/export');
3
3
  var anObject = require('../internals/an-object');
4
4
  var anObjectOrUndefined = require('../internals/an-object-or-undefined');
5
+ var createProperty = require('../internals/create-property');
5
6
  var call = require('../internals/function-call');
6
7
  var uncurryThis = require('../internals/function-uncurry-this');
7
8
  var getBuiltIn = require('../internals/get-built-in');
@@ -62,7 +63,7 @@ $({ target: 'Iterator', stat: true, forced: true }, {
62
63
  return iteratorZip(iters, mode, padding, function (results) {
63
64
  var obj = create(null);
64
65
  for (var j = 0; j < iterCount; j++) {
65
- obj[keys[j]] = results[j];
66
+ createProperty(obj, keys[j], results[j]);
66
67
  }
67
68
  return obj;
68
69
  });
@@ -3,6 +3,7 @@ var $ = require('../internals/export');
3
3
  var aCallable = require('../internals/a-callable');
4
4
  var aMap = require('../internals/a-map');
5
5
  var MapHelpers = require('../internals/map-helpers');
6
+ var IS_PURE = require('../internals/is-pure');
6
7
 
7
8
  var get = MapHelpers.get;
8
9
  var has = MapHelpers.has;
@@ -10,7 +11,7 @@ var set = MapHelpers.set;
10
11
 
11
12
  // `Map.prototype.getOrInsertComputed` method
12
13
  // https://github.com/tc39/proposal-upsert
13
- $({ target: 'Map', proto: true, real: true }, {
14
+ $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
14
15
  getOrInsertComputed: function getOrInsertComputed(key, callbackfn) {
15
16
  aMap(this);
16
17
  aCallable(callbackfn);
@@ -2,6 +2,7 @@
2
2
  var $ = require('../internals/export');
3
3
  var aMap = require('../internals/a-map');
4
4
  var MapHelpers = require('../internals/map-helpers');
5
+ var IS_PURE = require('../internals/is-pure');
5
6
 
6
7
  var get = MapHelpers.get;
7
8
  var has = MapHelpers.has;
@@ -9,7 +10,7 @@ var set = MapHelpers.set;
9
10
 
10
11
  // `Map.prototype.getOrInsert` method
11
12
  // https://github.com/tc39/proposal-upsert
12
- $({ target: 'Map', proto: true, real: true }, {
13
+ $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
13
14
  getOrInsert: function getOrInsert(key, value) {
14
15
  if (has(aMap(this), key)) return get(this, key);
15
16
  set(this, key, value);
@@ -4,14 +4,26 @@ var aCallable = require('../internals/a-callable');
4
4
  var aWeakMap = require('../internals/a-weak-map');
5
5
  var aWeakKey = require('../internals/a-weak-key');
6
6
  var WeakMapHelpers = require('../internals/weak-map-helpers');
7
+ var IS_PURE = require('../internals/is-pure');
7
8
 
8
9
  var get = WeakMapHelpers.get;
9
10
  var has = WeakMapHelpers.has;
10
11
  var set = WeakMapHelpers.set;
11
12
 
13
+ var FORCED = IS_PURE || !function () {
14
+ try {
15
+ // eslint-disable-next-line es/no-weak-map, no-throw-literal -- testing
16
+ if (WeakMap.prototype.getOrInsertComputed) new WeakMap().getOrInsertComputed(1, function () { throw 1; });
17
+ } catch (error) {
18
+ // FF144 Nightly - Beta 3 bug
19
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1988369
20
+ return error instanceof TypeError;
21
+ }
22
+ }();
23
+
12
24
  // `WeakMap.prototype.getOrInsertComputed` method
13
25
  // https://github.com/tc39/proposal-upsert
14
- $({ target: 'WeakMap', proto: true, real: true }, {
26
+ $({ target: 'WeakMap', proto: true, real: true, forced: FORCED }, {
15
27
  getOrInsertComputed: function getOrInsertComputed(key, callbackfn) {
16
28
  aWeakMap(this);
17
29
  aWeakKey(key);
@@ -2,6 +2,7 @@
2
2
  var $ = require('../internals/export');
3
3
  var aWeakMap = require('../internals/a-weak-map');
4
4
  var WeakMapHelpers = require('../internals/weak-map-helpers');
5
+ var IS_PURE = require('../internals/is-pure');
5
6
 
6
7
  var get = WeakMapHelpers.get;
7
8
  var has = WeakMapHelpers.has;
@@ -9,7 +10,7 @@ var set = WeakMapHelpers.set;
9
10
 
10
11
  // `WeakMap.prototype.getOrInsert` method
11
12
  // https://github.com/tc39/proposal-upsert
12
- $({ target: 'WeakMap', proto: true, real: true }, {
13
+ $({ target: 'WeakMap', proto: true, real: true, forced: IS_PURE }, {
13
14
  getOrInsert: function getOrInsert(key, value) {
14
15
  if (has(aWeakMap(this), key)) return get(this, key);
15
16
  set(this, key, value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-js-pure",
3
- "version": "3.45.0",
3
+ "version": "3.46.0",
4
4
  "type": "commonjs",
5
5
  "description": "Standard library",
6
6
  "keywords": [
@@ -56,6 +56,10 @@
56
56
  "url": "git+https://github.com/zloirock/core-js.git",
57
57
  "directory": "packages/core-js-pure"
58
58
  },
59
+ "homepage": "https://core-js.io",
60
+ "bugs": {
61
+ "url": "https://github.com/zloirock/core-js/issues"
62
+ },
59
63
  "funding": {
60
64
  "type": "opencollective",
61
65
  "url": "https://opencollective.com/core-js"
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+ // https://github.com/tc39/proposal-iterator-chunking
3
+ require('../modules/esnext.iterator.chunks');
4
+ require('../modules/esnext.iterator.windows');
package/stage/2.7.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
  var parent = require('./3');
3
3
 
4
+ require('../proposals/iterator-chunking');
4
5
  require('../proposals/joint-iteration');
5
6
 
6
7
  module.exports = parent;
package/stage/2.js CHANGED
@@ -4,7 +4,6 @@ var parent = require('./2.7');
4
4
  require('../proposals/array-is-template-object');
5
5
  require('../proposals/async-iterator-helpers');
6
6
  require('../proposals/extractors');
7
- require('../proposals/iterator-chunking');
8
7
  require('../proposals/iterator-range');
9
8
  require('../proposals/string-dedent');
10
9
  require('../proposals/symbol-predicates-v2');