diff --git a/CHANGELOG.md b/CHANGELOG.md index 943a6bc99b97..96b6220b7f34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,30 @@ ## Changelog ##### Unreleased -- [`Promise.try` proposal](https://github.com/tc39/proposal-promise-try) has been resurrected and [moved to stage 2](https://github.com/tc39/proposal-promise-try/issues/15), Febrary 2024 TC39 meeting -- Fixed regression in `Set#intersection` feature detection -- Fixed a missed check in `Array#{ indexOf, lastIndexOf, includes }`, [#1325](https://github.com/zloirock/core-js/issues/1325), thanks [**@minseok-choe**](https://github.com/minseok-choe) -- Fixed a missed check in `Array#{ reduce, reduceRight }`, [#1327](https://github.com/zloirock/core-js/issues/1327), thanks [**@minseok-choe**](https://github.com/minseok-choe) +- [`ArrayBuffer.prototype.transfer` and friends proposal](https://github.com/tc39/proposal-arraybuffer-transfer): + - Built-ins: + - `ArrayBuffer.prototype.detached` + - `ArrayBuffer.prototype.transfer` + - `ArrayBuffer.prototype.transferToFixedLength` + - Moved to stable ES, [Febrary 2024 TC39 meeting](https://twitter.com/ljharb/status/1755025758219841987) + - Added `es.` namespace modules, `/es/` and `/stable/` namespaces entries +- [`Promise.try` proposal](https://github.com/tc39/proposal-promise-try) has been resurrected and moved to stage 2, [Febrary 2024 TC39 meeting](https://github.com/tc39/proposal-promise-try/issues/15) +- Fixed regression in `Set.prototype.intersection` feature detection +- Fixed a missed check in `Array.prototype.{ indexOf, lastIndexOf, includes }`, [#1325](https://github.com/zloirock/core-js/issues/1325), thanks [**@minseok-choe**](https://github.com/minseok-choe) +- Fixed a missed check in `Array.prototype.{ reduce, reduceRight }`, [#1327](https://github.com/zloirock/core-js/issues/1327), thanks [**@minseok-choe**](https://github.com/minseok-choe) - Fixed `Array.from` and some other methods with proxy targets, [#1322](https://github.com/zloirock/core-js/issues/1322), thanks [**@minseok-choe**](https://github.com/minseok-choe) - Dropped context workaround from collection static methods entries since with current methods semantic it's no longer required - Added instance methods polyfills to entries of collections static methods that produce collection instances -- Added missed `Date#toJSON` to `JSON.stringify` entries dependencies +- Added missed `Date.prototype.toJSON` to `JSON.stringify` entries dependencies - Added debugging info in some missed cases - Compat data improvements: - - [`{ Map, Object }.groupBy`](https://github.com/tc39/proposal-array-grouping), [`Promise.withResolvers`](https://github.com/tc39/proposal-promise-with-resolvers), [`ArrayBuffer#transfer` and friends](https://github.com/tc39/proposal-arraybuffer-transfer) marked as supported from [Safari 17.4](https://developer.apple.com/documentation/safari-release-notes/safari-17_4-release-notes#JavaScript) + - [`{ Map, Object }.groupBy`](https://github.com/tc39/proposal-array-grouping), [`Promise.withResolvers`](https://github.com/tc39/proposal-promise-with-resolvers), [`ArrayBuffer.prototype.transfer` and friends](https://github.com/tc39/proposal-arraybuffer-transfer) marked as supported from [Safari 17.4](https://developer.apple.com/documentation/safari-release-notes/safari-17_4-release-notes#JavaScript) - [New `Set` methods](https://github.com/tc39/proposal-set-methods) [fixed](https://bugs.chromium.org/p/v8/issues/detail?id=14559#c4) and marked as supported from V8 ~ Chrome 123 - Added [Deno 1.40](https://deno.com/blog/v1.40) compat data mapping - Updated Electron 30 compat data mapping ##### [3.35.1 - 2024.01.21](https://github.com/zloirock/core-js/releases/tag/v3.35.1) - Fixed internal `ToLength` operation with bigints, [#1318](https://github.com/zloirock/core-js/issues/1318) -- Removed significant redundant code from `String#split` polyfill +- Removed significant redundant code from `String.prototype.split` polyfill - Fixed setting names of methods with symbol keys in some old engines - Minor fix of prototype methods export logic in the pure version - Compat data improvements: diff --git a/packages/core-js-compat/src/data.mjs b/packages/core-js-compat/src/data.mjs index 199c5e83dcbe..0f0ad0f18cb7 100644 --- a/packages/core-js-compat/src/data.mjs +++ b/packages/core-js-compat/src/data.mjs @@ -440,6 +440,24 @@ export const data = { rhino: '1.7.13', safari: '12.1', }, + 'es.array-buffer.detached': { + bun: '1.0.19', + chrome: '114', + firefox: '122', + safari: '17.4', + }, + 'es.array-buffer.transfer': { + bun: '1.0.19', + chrome: '114', + firefox: '122', + safari: '17.4', + }, + 'es.array-buffer.transfer-to-fixed-length': { + bun: '1.0.19', + chrome: '114', + firefox: '122', + safari: '17.4', + }, // TODO: Remove this module from `core-js@4` since it's replaced to module below 'es.data-view': null, 'es.data-view.constructor': { @@ -1950,24 +1968,12 @@ export const data = { }, // TODO: Remove from `core-js@4` 'esnext.array.with': null, - 'esnext.array-buffer.detached': { - bun: '1.0.19', - chrome: '114', - firefox: '122', - safari: '17.4', - }, - 'esnext.array-buffer.transfer': { - bun: '1.0.19', - chrome: '114', - firefox: '122', - safari: '17.4', - }, - 'esnext.array-buffer.transfer-to-fixed-length': { - bun: '1.0.19', - chrome: '114', - firefox: '122', - safari: '17.4', - }, + // TODO: Remove from `core-js@4` + 'esnext.array-buffer.detached': null, + // TODO: Remove from `core-js@4` + 'esnext.array-buffer.transfer': null, + // TODO: Remove from `core-js@4` + 'esnext.array-buffer.transfer-to-fixed-length': null, 'esnext.async-disposable-stack.constructor': { }, 'esnext.async-iterator.constructor': { @@ -2687,6 +2693,9 @@ export const renamed = new Map([ ['esnext.array.to-sorted', 'es.array.to-sorted'], ['esnext.array.to-spliced', 'es.array.to-spliced'], ['esnext.array.with', 'es.array.with'], + ['esnext.array-buffer.detached', 'es.array-buffer.detached'], + ['esnext.array-buffer.transfer', 'es.array-buffer.transfer'], + ['esnext.array-buffer.transfer-to-fixed-length', 'es.array-buffer.transfer-to-fixed-length'], ['esnext.aggregate-error', 'es.aggregate-error'], ['esnext.global-this', 'es.global-this'], ['esnext.map.group-by', 'es.map.group-by'], diff --git a/packages/core-js-compat/src/modules-by-versions.mjs b/packages/core-js-compat/src/modules-by-versions.mjs index fafe14b1b1b3..6565c15cac96 100644 --- a/packages/core-js-compat/src/modules-by-versions.mjs +++ b/packages/core-js-compat/src/modules-by-versions.mjs @@ -232,4 +232,9 @@ export default { 'esnext.uint8-array.to-base64', 'esnext.uint8-array.to-hex', ], + 3.36: [ + 'es.array-buffer.detached', + 'es.array-buffer.transfer', + 'es.array-buffer.transfer-to-fixed-length', + ], }; diff --git a/packages/core-js-pure/override/modules/es.array-buffer.detached.js b/packages/core-js-pure/override/modules/es.array-buffer.detached.js new file mode 100644 index 000000000000..8b1a393741c9 --- /dev/null +++ b/packages/core-js-pure/override/modules/es.array-buffer.detached.js @@ -0,0 +1 @@ +// empty diff --git a/packages/core-js-pure/override/modules/es.array-buffer.transfer-to-fixed-length.js b/packages/core-js-pure/override/modules/es.array-buffer.transfer-to-fixed-length.js new file mode 100644 index 000000000000..8b1a393741c9 --- /dev/null +++ b/packages/core-js-pure/override/modules/es.array-buffer.transfer-to-fixed-length.js @@ -0,0 +1 @@ +// empty diff --git a/packages/core-js-pure/override/modules/es.array-buffer.transfer.js b/packages/core-js-pure/override/modules/es.array-buffer.transfer.js new file mode 100644 index 000000000000..8b1a393741c9 --- /dev/null +++ b/packages/core-js-pure/override/modules/es.array-buffer.transfer.js @@ -0,0 +1 @@ +// empty diff --git a/packages/core-js/actual/array-buffer/detached.js b/packages/core-js/actual/array-buffer/detached.js index 4952c84ea9b5..886101073dc4 100644 --- a/packages/core-js/actual/array-buffer/detached.js +++ b/packages/core-js/actual/array-buffer/detached.js @@ -1,3 +1,5 @@ 'use strict'; -require('../../stable/array-buffer'); +var parent = require('../../stable/array-buffer/detached'); require('../../modules/esnext.array-buffer.detached'); + +module.exports = parent; diff --git a/packages/core-js/actual/array-buffer/transfer-to-fixed-length.js b/packages/core-js/actual/array-buffer/transfer-to-fixed-length.js index a5fa2b4daf3c..2d5e4c869384 100644 --- a/packages/core-js/actual/array-buffer/transfer-to-fixed-length.js +++ b/packages/core-js/actual/array-buffer/transfer-to-fixed-length.js @@ -1,3 +1,5 @@ 'use strict'; -require('../../stable/array-buffer'); +var parent = require('../../stable/array-buffer/transfer-to-fixed-length'); require('../../modules/esnext.array-buffer.transfer-to-fixed-length'); + +module.exports = parent; diff --git a/packages/core-js/actual/array-buffer/transfer.js b/packages/core-js/actual/array-buffer/transfer.js index 3f3f4a5d7e17..9f1700af3be0 100644 --- a/packages/core-js/actual/array-buffer/transfer.js +++ b/packages/core-js/actual/array-buffer/transfer.js @@ -1,3 +1,5 @@ 'use strict'; -require('../../stable/array-buffer'); +var parent = require('../../stable/array-buffer/transfer'); require('../../modules/esnext.array-buffer.transfer'); + +module.exports = parent; diff --git a/packages/core-js/es/array-buffer/constructor.js b/packages/core-js/es/array-buffer/constructor.js index 48fb2735ed29..3a375e08e71d 100644 --- a/packages/core-js/es/array-buffer/constructor.js +++ b/packages/core-js/es/array-buffer/constructor.js @@ -1,6 +1,9 @@ 'use strict'; require('../../modules/es.array-buffer.constructor'); require('../../modules/es.array-buffer.slice'); +require('../../modules/es.array-buffer.detached'); +require('../../modules/es.array-buffer.transfer'); +require('../../modules/es.array-buffer.transfer-to-fixed-length'); require('../../modules/es.object.to-string'); var path = require('../../internals/path'); diff --git a/packages/core-js/es/array-buffer/detached.js b/packages/core-js/es/array-buffer/detached.js new file mode 100644 index 000000000000..2c0ec734a726 --- /dev/null +++ b/packages/core-js/es/array-buffer/detached.js @@ -0,0 +1,4 @@ +'use strict'; +require('../../modules/es.array-buffer.constructor'); +require('../../modules/es.array-buffer.slice'); +require('../../modules/es.array-buffer.detached'); diff --git a/packages/core-js/es/array-buffer/index.js b/packages/core-js/es/array-buffer/index.js index 6681be930089..7525db2db9a9 100644 --- a/packages/core-js/es/array-buffer/index.js +++ b/packages/core-js/es/array-buffer/index.js @@ -2,6 +2,9 @@ require('../../modules/es.array-buffer.constructor'); require('../../modules/es.array-buffer.is-view'); require('../../modules/es.array-buffer.slice'); +require('../../modules/es.array-buffer.detached'); +require('../../modules/es.array-buffer.transfer'); +require('../../modules/es.array-buffer.transfer-to-fixed-length'); require('../../modules/es.object.to-string'); var path = require('../../internals/path'); diff --git a/packages/core-js/es/array-buffer/transfer-to-fixed-length.js b/packages/core-js/es/array-buffer/transfer-to-fixed-length.js new file mode 100644 index 000000000000..e7bcba790bb0 --- /dev/null +++ b/packages/core-js/es/array-buffer/transfer-to-fixed-length.js @@ -0,0 +1,4 @@ +'use strict'; +require('../../modules/es.array-buffer.constructor'); +require('../../modules/es.array-buffer.slice'); +require('../../modules/es.array-buffer.transfer-to-fixed-length'); diff --git a/packages/core-js/es/array-buffer/transfer.js b/packages/core-js/es/array-buffer/transfer.js new file mode 100644 index 000000000000..2f63e7ffb94c --- /dev/null +++ b/packages/core-js/es/array-buffer/transfer.js @@ -0,0 +1,4 @@ +'use strict'; +require('../../modules/es.array-buffer.constructor'); +require('../../modules/es.array-buffer.slice'); +require('../../modules/es.array-buffer.transfer'); diff --git a/packages/core-js/modules/es.array-buffer.detached.js b/packages/core-js/modules/es.array-buffer.detached.js new file mode 100644 index 000000000000..3aa6d9c36ab6 --- /dev/null +++ b/packages/core-js/modules/es.array-buffer.detached.js @@ -0,0 +1,15 @@ +'use strict'; +var DESCRIPTORS = require('../internals/descriptors'); +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); +var isDetached = require('../internals/array-buffer-is-detached'); + +var ArrayBufferPrototype = ArrayBuffer.prototype; + +if (DESCRIPTORS && !('detached' in ArrayBufferPrototype)) { + defineBuiltInAccessor(ArrayBufferPrototype, 'detached', { + configurable: true, + get: function detached() { + return isDetached(this); + } + }); +} diff --git a/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js b/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js new file mode 100644 index 000000000000..55a9f8a7f08a --- /dev/null +++ b/packages/core-js/modules/es.array-buffer.transfer-to-fixed-length.js @@ -0,0 +1,11 @@ +'use strict'; +var $ = require('../internals/export'); +var $transfer = require('../internals/array-buffer-transfer'); + +// `ArrayBuffer.prototype.transferToFixedLength` method +// https://tc39.es/proposal-arraybuffer-transfer/#sec-arraybuffer.prototype.transfertofixedlength +if ($transfer) $({ target: 'ArrayBuffer', proto: true }, { + transferToFixedLength: function transferToFixedLength() { + return $transfer(this, arguments.length ? arguments[0] : undefined, false); + } +}); diff --git a/packages/core-js/modules/es.array-buffer.transfer.js b/packages/core-js/modules/es.array-buffer.transfer.js new file mode 100644 index 000000000000..197658dee9d0 --- /dev/null +++ b/packages/core-js/modules/es.array-buffer.transfer.js @@ -0,0 +1,11 @@ +'use strict'; +var $ = require('../internals/export'); +var $transfer = require('../internals/array-buffer-transfer'); + +// `ArrayBuffer.prototype.transfer` method +// https://tc39.es/proposal-arraybuffer-transfer/#sec-arraybuffer.prototype.transfer +if ($transfer) $({ target: 'ArrayBuffer', proto: true }, { + transfer: function transfer() { + return $transfer(this, arguments.length ? arguments[0] : undefined, true); + } +}); diff --git a/packages/core-js/modules/esnext.array-buffer.detached.js b/packages/core-js/modules/esnext.array-buffer.detached.js index 3aa6d9c36ab6..c8db3f0b6c1c 100644 --- a/packages/core-js/modules/esnext.array-buffer.detached.js +++ b/packages/core-js/modules/esnext.array-buffer.detached.js @@ -1,15 +1,3 @@ 'use strict'; -var DESCRIPTORS = require('../internals/descriptors'); -var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); -var isDetached = require('../internals/array-buffer-is-detached'); - -var ArrayBufferPrototype = ArrayBuffer.prototype; - -if (DESCRIPTORS && !('detached' in ArrayBufferPrototype)) { - defineBuiltInAccessor(ArrayBufferPrototype, 'detached', { - configurable: true, - get: function detached() { - return isDetached(this); - } - }); -} +// TODO: Remove from `core-js@4` +require('../modules/es.array-buffer.detached'); diff --git a/packages/core-js/modules/esnext.array-buffer.transfer-to-fixed-length.js b/packages/core-js/modules/esnext.array-buffer.transfer-to-fixed-length.js index 55a9f8a7f08a..9bc38ebda51b 100644 --- a/packages/core-js/modules/esnext.array-buffer.transfer-to-fixed-length.js +++ b/packages/core-js/modules/esnext.array-buffer.transfer-to-fixed-length.js @@ -1,11 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var $transfer = require('../internals/array-buffer-transfer'); - -// `ArrayBuffer.prototype.transferToFixedLength` method -// https://tc39.es/proposal-arraybuffer-transfer/#sec-arraybuffer.prototype.transfertofixedlength -if ($transfer) $({ target: 'ArrayBuffer', proto: true }, { - transferToFixedLength: function transferToFixedLength() { - return $transfer(this, arguments.length ? arguments[0] : undefined, false); - } -}); +// TODO: Remove from `core-js@4` +require('../modules/es.array-buffer.transfer-to-fixed-length'); diff --git a/packages/core-js/modules/esnext.array-buffer.transfer.js b/packages/core-js/modules/esnext.array-buffer.transfer.js index 197658dee9d0..f5f939ba7244 100644 --- a/packages/core-js/modules/esnext.array-buffer.transfer.js +++ b/packages/core-js/modules/esnext.array-buffer.transfer.js @@ -1,11 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var $transfer = require('../internals/array-buffer-transfer'); - -// `ArrayBuffer.prototype.transfer` method -// https://tc39.es/proposal-arraybuffer-transfer/#sec-arraybuffer.prototype.transfer -if ($transfer) $({ target: 'ArrayBuffer', proto: true }, { - transfer: function transfer() { - return $transfer(this, arguments.length ? arguments[0] : undefined, true); - } -}); +// TODO: Remove from `core-js@4` +require('../modules/es.array-buffer.transfer'); diff --git a/packages/core-js/stable/array-buffer/detached.js b/packages/core-js/stable/array-buffer/detached.js new file mode 100644 index 000000000000..ad4679dc1c21 --- /dev/null +++ b/packages/core-js/stable/array-buffer/detached.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/array-buffer/detached'); + +module.exports = parent; diff --git a/packages/core-js/stable/array-buffer/transfer-to-fixed-length.js b/packages/core-js/stable/array-buffer/transfer-to-fixed-length.js new file mode 100644 index 000000000000..4e183bdae662 --- /dev/null +++ b/packages/core-js/stable/array-buffer/transfer-to-fixed-length.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/array-buffer/transfer-to-fixed-length'); + +module.exports = parent; diff --git a/packages/core-js/stable/array-buffer/transfer.js b/packages/core-js/stable/array-buffer/transfer.js new file mode 100644 index 000000000000..cca11f3640f4 --- /dev/null +++ b/packages/core-js/stable/array-buffer/transfer.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/array-buffer/transfer'); + +module.exports = parent; diff --git a/packages/core-js/stage/3.js b/packages/core-js/stage/3.js index e82ca7059331..80aee396ff48 100644 --- a/packages/core-js/stage/3.js +++ b/packages/core-js/stage/3.js @@ -1,7 +1,6 @@ 'use strict'; var parent = require('./4'); -require('../proposals/array-buffer-transfer'); require('../proposals/array-from-async-stage-2'); require('../proposals/decorator-metadata-v2'); require('../proposals/explicit-resource-management'); diff --git a/packages/core-js/stage/4.js b/packages/core-js/stage/4.js index fa0f07787508..a3b129992211 100644 --- a/packages/core-js/stage/4.js +++ b/packages/core-js/stage/4.js @@ -1,6 +1,7 @@ 'use strict'; // TODO: Remove this entry from `core-js@4` require('../proposals/accessible-object-hasownproperty'); +require('../proposals/array-buffer-transfer'); require('../proposals/array-find-from-last'); require('../proposals/array-grouping-v2'); require('../proposals/change-array-by-copy-stage-4'); diff --git a/tests/compat/tests.js b/tests/compat/tests.js index 535586872ae7..69a8e9162446 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -615,6 +615,15 @@ GLOBAL.tests = { 'es.array-buffer.slice': [ARRAY_BUFFER_SUPPORT, function () { return new ArrayBuffer(2).slice(1, undefined).byteLength; }], + 'es.array-buffer.detached': function () { + return 'detached' in ArrayBuffer.prototype; + }, + 'es.array-buffer.transfer': function () { + return ArrayBuffer.prototype.transfer; + }, + 'es.array-buffer.transfer-to-fixed-length': function () { + return ArrayBuffer.prototype.transferToFixedLength; + }, 'es.data-view.constructor': ARRAY_BUFFER_SUPPORT, 'es.date.get-year': function () { return new Date(16e11).getYear() === 120; @@ -1516,15 +1525,6 @@ GLOBAL.tests = { 'esnext.array.unique-by': function () { return [].uniqueBy; }, - 'esnext.array-buffer.detached': function () { - return 'detached' in ArrayBuffer.prototype; - }, - 'esnext.array-buffer.transfer': function () { - return ArrayBuffer.prototype.transfer; - }, - 'esnext.array-buffer.transfer-to-fixed-length': function () { - return ArrayBuffer.prototype.transferToFixedLength; - }, 'esnext.async-disposable-stack.constructor': function () { return typeof AsyncDisposableStack == 'function'; }, diff --git a/tests/entries/unit.mjs b/tests/entries/unit.mjs index ea75da8bcedf..dc8494cb25a7 100644 --- a/tests/entries/unit.mjs +++ b/tests/entries/unit.mjs @@ -660,9 +660,6 @@ for (PATH of ['core-js-pure', 'core-js']) { ok(typeof load(NS, 'array/virtual/group-to-map') == 'function'); ok(typeof load(NS, 'array/virtual/group-by') == 'function'); ok(typeof load(NS, 'array/virtual/group-by-to-map') == 'function'); - load(NS, 'array-buffer/detached'); - load(NS, 'array-buffer/transfer'); - load(NS, 'array-buffer/transfer-to-fixed-length'); ok(typeof load(NS, 'async-iterator') == 'function'); ok(typeof load(NS, 'async-iterator/drop') == 'function'); ok(typeof load(NS, 'async-iterator/every') == 'function'); @@ -1016,6 +1013,9 @@ for (const NS of ['es', 'stable', 'actual', 'full', 'features']) { ok(typeof load(NS, 'array-buffer/constructor') == 'function'); ok(typeof load(NS, 'array-buffer/is-view') == 'function'); load(NS, 'array-buffer/slice'); + load(NS, 'array-buffer/detached'); + load(NS, 'array-buffer/transfer'); + load(NS, 'array-buffer/transfer-to-fixed-length'); ok(typeof load(NS, 'data-view') == 'function'); ok(typeof load(NS, 'typed-array/int8-array') == 'function'); ok(typeof load(NS, 'typed-array/uint8-array') == 'function'); diff --git a/tests/unit-global/esnext.array-buffer.detached.js b/tests/unit-global/es.array-buffer.detached.js similarity index 100% rename from tests/unit-global/esnext.array-buffer.detached.js rename to tests/unit-global/es.array-buffer.detached.js diff --git a/tests/unit-global/esnext.array-buffer.transfer-to-fixed-length.js b/tests/unit-global/es.array-buffer.transfer-to-fixed-length.js similarity index 100% rename from tests/unit-global/esnext.array-buffer.transfer-to-fixed-length.js rename to tests/unit-global/es.array-buffer.transfer-to-fixed-length.js diff --git a/tests/unit-global/esnext.array-buffer.transfer.js b/tests/unit-global/es.array-buffer.transfer.js similarity index 100% rename from tests/unit-global/esnext.array-buffer.transfer.js rename to tests/unit-global/es.array-buffer.transfer.js