Skip to content

Commit

Permalink
move ArrayBuffer.prototype.transfer and friends to stable ES
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Feb 8, 2024
1 parent 582e4e1 commit 4c51d71
Show file tree
Hide file tree
Showing 30 changed files with 144 additions and 75 deletions.
21 changes: 14 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
45 changes: 27 additions & 18 deletions packages/core-js-compat/src/data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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': {
Expand Down Expand Up @@ -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'],
Expand Down
5 changes: 5 additions & 0 deletions packages/core-js-compat/src/modules-by-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty
4 changes: 3 additions & 1 deletion packages/core-js/actual/array-buffer/detached.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 3 additions & 1 deletion packages/core-js/actual/array-buffer/transfer.js
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions packages/core-js/es/array-buffer/constructor.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
4 changes: 4 additions & 0 deletions packages/core-js/es/array-buffer/detached.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
require('../../modules/es.array-buffer.constructor');
require('../../modules/es.array-buffer.slice');
require('../../modules/es.array-buffer.detached');
3 changes: 3 additions & 0 deletions packages/core-js/es/array-buffer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
4 changes: 4 additions & 0 deletions packages/core-js/es/array-buffer/transfer-to-fixed-length.js
Original file line number Diff line number Diff line change
@@ -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');
4 changes: 4 additions & 0 deletions packages/core-js/es/array-buffer/transfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
require('../../modules/es.array-buffer.constructor');
require('../../modules/es.array-buffer.slice');
require('../../modules/es.array-buffer.transfer');
15 changes: 15 additions & 0 deletions packages/core-js/modules/es.array-buffer.detached.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
}
Original file line number Diff line number Diff line change
@@ -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);
}
});
11 changes: 11 additions & 0 deletions packages/core-js/modules/es.array-buffer.transfer.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
16 changes: 2 additions & 14 deletions packages/core-js/modules/esnext.array-buffer.detached.js
Original file line number Diff line number Diff line change
@@ -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');
Original file line number Diff line number Diff line change
@@ -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');
12 changes: 2 additions & 10 deletions packages/core-js/modules/esnext.array-buffer.transfer.js
Original file line number Diff line number Diff line change
@@ -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');
4 changes: 4 additions & 0 deletions packages/core-js/stable/array-buffer/detached.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
var parent = require('../../es/array-buffer/detached');

module.exports = parent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
var parent = require('../../es/array-buffer/transfer-to-fixed-length');

module.exports = parent;
4 changes: 4 additions & 0 deletions packages/core-js/stable/array-buffer/transfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
var parent = require('../../es/array-buffer/transfer');

module.exports = parent;
1 change: 0 additions & 1 deletion packages/core-js/stage/3.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
1 change: 1 addition & 0 deletions packages/core-js/stage/4.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
18 changes: 9 additions & 9 deletions tests/compat/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
},
Expand Down
6 changes: 3 additions & 3 deletions tests/entries/unit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 4c51d71

Please sign in to comment.