Skip to content

Commit 559081f

Browse files
committed
move new Set methods to stable ES
1 parent 5e703c4 commit 559081f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+337
-207
lines changed

README.md

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3])
154154
- [`Symbol.prototype.description`](#symbolprototypedescription)
155155
- [Well-formed `JSON.stringify`](#well-formed-jsonstringify)
156156
- [Well-formed unicode strings](#well-formed-unicode-strings)
157+
- [New `Set` methods](#new-set-methods)
157158
- [Stage 3 proposals](#stage-3-proposals)
158159
- [`Iterator` helpers](#iterator-helpers)
159160
- [`Array.fromAsync`](#arrayfromasync)
160-
- [New `Set` methods](#new-set-methods)
161161
- [`JSON.parse` source text access](#jsonparse-source-text-access)
162162
- [`Float16` methods](#float16-methods)
163163
- [Explicit resource management](#explicit-resource-management)
@@ -1499,7 +1499,7 @@ map.get(1); // => [1, 3, 5]
14991499
map.get(0); // => [2, 4]
15001500
```
15011501
#### Set[⬆](#index)
1502-
Module [`es.set`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.js).
1502+
Modules [`es.set`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.js), [`es.set.difference.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.difference.v2.js), [`es.set.intersection.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.intersection.v2.js), [`es.set.is-disjoint-from.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.is-disjoint-from.v2.js), [`es.set.is-subset-of.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.is-subset-of.v2.js), [`es.set.is-superset-of.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.is-superset-of.v2.js), [`es.set.symmetric-difference.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.symmetric-difference.v2.js), [`es.set.union.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.union.v2.js)
15031503
```js
15041504
class Set {
15051505
constructor(iterable?: Iterable<value>): Set;
@@ -1511,15 +1511,29 @@ class Set {
15111511
values(): Iterator<value>;
15121512
keys(): Iterator<value>;
15131513
entries(): Iterator<[value, value]>;
1514+
difference(other: SetLike<mixed>): Set;
1515+
intersection(other: SetLike<mixed>): Set;
1516+
isDisjointFrom(other: SetLike<mixed>): boolean;
1517+
isSubsetOf(other: SetLike<mixed>): boolean;
1518+
isSupersetOf(other: SetLike<mixed>): boolean;
1519+
symmetricDifference(other: SetLike<mixed>): Set;
1520+
union(other: SetLike<mixed>): Set;
15141521
@@iterator(): Iterator<value>;
15151522
readonly attribute size: number;
15161523
}
15171524
```
15181525
[*CommonJS entry points:*](#commonjs-api)
15191526
```
15201527
core-js(-pure)/es|stable|actual|full/set
1528+
core-js(-pure)/es|stable|actual|full/set/difference
1529+
core-js(-pure)/es|stable|actual|full/set/intersection
1530+
core-js(-pure)/es|stable|actual|full/set/is-disjoint-from
1531+
core-js(-pure)/es|stable|actual|full/set/is-subset-of
1532+
core-js(-pure)/es|stable|actual|full/set/is-superset-of
1533+
core-js(-pure)/es|stable|actual|full/set/symmetric-difference
1534+
core-js(-pure)/es|stable|actual|full/set/union
15211535
```
1522-
[*Examples*](https://goo.gl/bmhLwg):
1536+
[*Examples*](https://tinyurl.com/2dy5t9ey):
15231537
```js
15241538
let set = new Set(['a', 'b', 'a', 'c']);
15251539
set.add('d').add('b').add('e');
@@ -1542,6 +1556,14 @@ for (let [key, value] of set.entries()) {
15421556
console.log(key); // => 1, 2, 3
15431557
console.log(value); // => 1, 2, 3
15441558
}
1559+
1560+
new Set([1, 2, 3]).union(new Set([3, 4, 5])); // => Set {1, 2, 3, 4, 5}
1561+
new Set([1, 2, 3]).intersection(new Set([3, 4, 5])); // => Set {3}
1562+
new Set([1, 2, 3]).difference(new Set([3, 4, 5])); // => Set {1, 2}
1563+
new Set([1, 2, 3]).symmetricDifference(new Set([3, 4, 5])); // => Set {1, 2, 4, 5}
1564+
new Set([1, 2, 3]).isDisjointFrom(new Set([4, 5, 6])); // => true
1565+
new Set([1, 2, 3]).isSubsetOf(new Set([5, 4, 3, 2, 1])); // => true
1566+
new Set([5, 4, 3, 2, 1]).isSupersetOf(new Set([1, 2, 3])); // => true
15451567
```
15461568
#### WeakMap[⬆](#index)
15471569
Module [`es.weak-map`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.weak-map.js).
@@ -2236,6 +2258,22 @@ class String {
22362258
```js
22372259
core-js/proposals/well-formed-unicode-strings
22382260
```
2261+
##### [New `Set` methods](https://github.com/tc39/proposal-set-methods)[⬆](#index)
2262+
```js
2263+
class Set {
2264+
difference(other: SetLike<mixed>): Set;
2265+
intersection(other: SetLike<mixed>): Set;
2266+
isDisjointFrom(other: SetLike<mixed>): boolean;
2267+
isSubsetOf(other: SetLike<mixed>): boolean;
2268+
isSupersetOf(other: SetLike<mixed>): boolean;
2269+
symmetricDifference(other: SetLike<mixed>): Set;
2270+
union(other: SetLike<mixed>): Set;
2271+
}
2272+
```
2273+
[*CommonJS entry points:*](#commonjs-api)
2274+
```js
2275+
core-js/proposals/set-methods-v2
2276+
```
22392277

22402278
#### Stage 3 proposals[⬆](#index)
22412279

@@ -2314,40 +2352,6 @@ core-js(-pure)/actual|full/array/from-async
23142352
```js
23152353
await Array.fromAsync((async function * (){ yield * [1, 2, 3] })(), i => i * i); // => [1, 4, 9]
23162354
```
2317-
##### [New `Set` methods](https://github.com/tc39/proposal-set-methods)[⬆](#index)
2318-
Modules [`esnext.set.difference.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.set.difference.v2.js), [`esnext.set.intersection.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.set.intersection.v2.js), [`esnext.set.is-disjoint-from.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.set.is-disjoint-from.v2.js), [`esnext.set.is-subset-of.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.set.is-subset-of.v2.js), [`esnext.set.is-superset-of.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.set.is-superset-of.v2.js), [`esnext.set.symmetric-difference.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.set.symmetric-difference.v2.js), [`esnext.set.union.v2`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.set.union.v2.js)
2319-
```js
2320-
class Set {
2321-
difference(other: SetLike<mixed>): Set;
2322-
intersection(other: SetLike<mixed>): Set;
2323-
isDisjointFrom(other: SetLike<mixed>): boolean;
2324-
isSubsetOf(other: SetLike<mixed>): boolean;
2325-
isSupersetOf(other: SetLike<mixed>): boolean;
2326-
symmetricDifference(other: SetLike<mixed>): Set;
2327-
union(other: SetLike<mixed>): Set;
2328-
}
2329-
```
2330-
[*CommonJS entry points:*](#commonjs-api)
2331-
```js
2332-
core-js/proposals/set-methods-v2
2333-
core-js(-pure)/actual|full/set/difference
2334-
core-js(-pure)/actual|full/set/intersection
2335-
core-js(-pure)/actual|full/set/is-disjoint-from
2336-
core-js(-pure)/actual|full/set/is-subset-of
2337-
core-js(-pure)/actual|full/set/is-superset-of
2338-
core-js(-pure)/actual|full/set/symmetric-difference
2339-
core-js(-pure)/actual|full/set/union
2340-
```
2341-
[*Examples*](https://tinyurl.com/2henaoac):
2342-
```js
2343-
new Set([1, 2, 3]).union(new Set([3, 4, 5])); // => Set {1, 2, 3, 4, 5}
2344-
new Set([1, 2, 3]).intersection(new Set([3, 4, 5])); // => Set {3}
2345-
new Set([1, 2, 3]).difference(new Set([3, 4, 5])); // => Set {1, 2}
2346-
new Set([1, 2, 3]).symmetricDifference(new Set([3, 4, 5])); // => Set {1, 2, 4, 5}
2347-
new Set([1, 2, 3]).isDisjointFrom(new Set([4, 5, 6])); // => true
2348-
new Set([1, 2, 3]).isSubsetOf(new Set([5, 4, 3, 2, 1])); // => true
2349-
new Set([5, 4, 3, 2, 1]).isSupersetOf(new Set([1, 2, 3])); // => true
2350-
```
23512355

23522356
##### [`JSON.parse` source text access](https://github.com/tc39/proposal-json-parse-with-source)[⬆](#index)
23532357
Modules [`esnext.json.is-raw-json`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.json.is-raw-json.js), [`esnext.json.parse`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.json.parse.js), [`esnext.json.raw-json`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.json.raw-json.js).

packages/core-js-compat/src/data.mjs

Lines changed: 84 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,69 @@ export const data = {
13481348
rhino: '1.7.13',
13491349
safari: '10.0',
13501350
},
1351+
'es.set.difference.v2': {
1352+
bun: '1.1.1',
1353+
// v8 ~ Chrome 122 do not properly work with set-like objects
1354+
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
1355+
chrome: '123',
1356+
// safari do not properly work with set-like objects
1357+
// https://bugs.webkit.org/show_bug.cgi?id=267494
1358+
// safari: '17.0',
1359+
},
1360+
'es.set.intersection.v2': {
1361+
bun: '1.1.1',
1362+
// v8 ~ Chrome 122 do not properly work with set-like objects
1363+
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
1364+
chrome: '123',
1365+
// safari do not properly work with set-like objects
1366+
// https://bugs.webkit.org/show_bug.cgi?id=267494
1367+
// safari: '17.0',
1368+
},
1369+
'es.set.is-disjoint-from.v2': {
1370+
bun: '1.1.1',
1371+
// v8 ~ Chrome 122 do not properly work with set-like objects
1372+
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
1373+
chrome: '123',
1374+
// safari do not properly work with set-like objects
1375+
// https://bugs.webkit.org/show_bug.cgi?id=267494
1376+
// safari: '17.0',
1377+
},
1378+
'es.set.is-subset-of.v2': {
1379+
bun: '1.1.1',
1380+
// v8 ~ Chrome 122 do not properly work with set-like objects
1381+
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
1382+
chrome: '123',
1383+
// safari do not properly work with set-like objects
1384+
// https://bugs.webkit.org/show_bug.cgi?id=267494
1385+
// safari: '17.0',
1386+
},
1387+
'es.set.is-superset-of.v2': {
1388+
bun: '1.1.1',
1389+
// v8 ~ Chrome 122 do not properly work with set-like objects
1390+
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
1391+
chrome: '123',
1392+
// safari do not properly work with set-like objects
1393+
// https://bugs.webkit.org/show_bug.cgi?id=267494
1394+
// safari: '17.0',
1395+
},
1396+
'es.set.symmetric-difference.v2': {
1397+
bun: '1.1.1',
1398+
// v8 ~ Chrome 122 do not properly work with set-like objects
1399+
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
1400+
chrome: '123',
1401+
// safari do not properly work with set-like objects
1402+
// https://bugs.webkit.org/show_bug.cgi?id=267494
1403+
// safari: '17.0',
1404+
},
1405+
'es.set.union.v2': {
1406+
bun: '1.1.1',
1407+
// v8 ~ Chrome 122 do not properly work with set-like objects
1408+
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
1409+
chrome: '123',
1410+
// safari do not properly work with set-like objects
1411+
// https://bugs.webkit.org/show_bug.cgi?id=267494
1412+
// safari: '17.0',
1413+
},
13511414
'es.string.at-alternative': {
13521415
chrome: '92',
13531416
firefox: '90',
@@ -2261,15 +2324,8 @@ export const data = {
22612324
},
22622325
'esnext.set.delete-all': {
22632326
},
2264-
'esnext.set.difference.v2': {
2265-
// v8 ~ Chrome 122 do not properly work with set-like objects
2266-
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
2267-
chrome: '123',
2268-
bun: '1.1.1',
2269-
// safari do not properly work with set-like objects
2270-
// https://bugs.webkit.org/show_bug.cgi?id=267494
2271-
// safari: '17.0',
2272-
},
2327+
// TODO: Remove from `core-js@4`
2328+
'esnext.set.difference.v2': null,
22732329
// TODO: Remove from `core-js@4`
22742330
'esnext.set.difference': {
22752331
},
@@ -2281,51 +2337,23 @@ export const data = {
22812337
},
22822338
'esnext.set.from': {
22832339
},
2284-
'esnext.set.intersection.v2': {
2285-
// v8 ~ Chrome 122 do not properly work with set-like objects
2286-
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
2287-
chrome: '123',
2288-
bun: '1.1.1',
2289-
// safari do not properly work with set-like objects
2290-
// https://bugs.webkit.org/show_bug.cgi?id=267494
2291-
// safari: '17.0',
2292-
},
2340+
// TODO: Remove from `core-js@4`
2341+
'esnext.set.intersection.v2': null,
22932342
// TODO: Remove from `core-js@4`
22942343
'esnext.set.intersection': {
22952344
},
2296-
'esnext.set.is-disjoint-from.v2': {
2297-
// v8 ~ Chrome 122 do not properly work with set-like objects
2298-
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
2299-
chrome: '123',
2300-
bun: '1.1.1',
2301-
// safari do not properly work with set-like objects
2302-
// https://bugs.webkit.org/show_bug.cgi?id=267494
2303-
// safari: '17.0',
2304-
},
2345+
// TODO: Remove from `core-js@4`
2346+
'esnext.set.is-disjoint-from.v2': null,
23052347
// TODO: Remove from `core-js@4`
23062348
'esnext.set.is-disjoint-from': {
23072349
},
2308-
'esnext.set.is-subset-of.v2': {
2309-
// v8 ~ Chrome 122 do not properly work with set-like objects
2310-
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
2311-
chrome: '123',
2312-
bun: '1.1.1',
2313-
// safari do not properly work with set-like objects
2314-
// https://bugs.webkit.org/show_bug.cgi?id=267494
2315-
// safari: '17.0',
2316-
},
2350+
// TODO: Remove from `core-js@4`
2351+
'esnext.set.is-subset-of.v2': null,
23172352
// TODO: Remove from `core-js@4`
23182353
'esnext.set.is-subset-of': {
23192354
},
2320-
'esnext.set.is-superset-of.v2': {
2321-
// v8 ~ Chrome 122 do not properly work with set-like objects
2322-
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
2323-
chrome: '123',
2324-
bun: '1.1.1',
2325-
// safari do not properly work with set-like objects
2326-
// https://bugs.webkit.org/show_bug.cgi?id=267494
2327-
// safari: '17.0',
2328-
},
2355+
// TODO: Remove from `core-js@4`
2356+
'esnext.set.is-superset-of.v2': null,
23292357
// TODO: Remove from `core-js@4`
23302358
'esnext.set.is-superset-of': {
23312359
},
@@ -2339,27 +2367,13 @@ export const data = {
23392367
},
23402368
'esnext.set.some': {
23412369
},
2342-
'esnext.set.symmetric-difference.v2': {
2343-
// v8 ~ Chrome 122 do not properly work with set-like objects
2344-
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
2345-
chrome: '123',
2346-
bun: '1.1.1',
2347-
// safari do not properly work with set-like objects
2348-
// https://bugs.webkit.org/show_bug.cgi?id=267494
2349-
// safari: '17.0',
2350-
},
2370+
// TODO: Remove from `core-js@4`
2371+
'esnext.set.symmetric-difference.v2': null,
23512372
// TODO: Remove from `core-js@4`
23522373
'esnext.set.symmetric-difference': {
23532374
},
2354-
'esnext.set.union.v2': {
2355-
// v8 ~ Chrome 122 do not properly work with set-like objects
2356-
// https://bugs.chromium.org/p/v8/issues/detail?id=14559
2357-
chrome: '123',
2358-
bun: '1.1.1',
2359-
// safari do not properly work with set-like objects
2360-
// https://bugs.webkit.org/show_bug.cgi?id=267494
2361-
// safari: '17.0',
2362-
},
2375+
// TODO: Remove from `core-js@4`
2376+
'esnext.set.union.v2': null,
23632377
// TODO: Remove from `core-js@4`
23642378
'esnext.set.union': {
23652379
},
@@ -2727,6 +2741,13 @@ export const renamed = new Map([
27272741
['esnext.promise.all-settled', 'es.promise.all-settled'],
27282742
['esnext.promise.any', 'es.promise.any'],
27292743
['esnext.promise.with-resolvers', 'es.promise.with-resolvers'],
2744+
['esnext.set.difference.v2', 'es.set.difference.v2'],
2745+
['esnext.set.intersection.v2', 'es.set.intersection.v2'],
2746+
['esnext.set.is-disjoint-from.v2', 'es.set.is-disjoint-from.v2'],
2747+
['esnext.set.is-subset-of.v2', 'es.set.is-subset-of.v2'],
2748+
['esnext.set.is-superset-of.v2', 'es.set.is-superset-of.v2'],
2749+
['esnext.set.symmetric-difference.v2', 'es.set.symmetric-difference.v2'],
2750+
['esnext.set.union.v2', 'es.set.union.v2'],
27302751
['esnext.string.is-well-formed', 'es.string.is-well-formed'],
27312752
['esnext.string.match-all', 'es.string.match-all'],
27322753
['esnext.string.replace-all', 'es.string.replace-all'],

packages/core-js-compat/src/modules-by-versions.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ export default {
238238
'es.array-buffer.transfer-to-fixed-length',
239239
],
240240
3.37: [
241+
'es.set.difference.v2',
242+
'es.set.intersection.v2',
243+
'es.set.is-disjoint-from.v2',
244+
'es.set.is-subset-of.v2',
245+
'es.set.is-superset-of.v2',
246+
'es.set.symmetric-difference.v2',
247+
'es.set.union.v2',
241248
'web.url.parse',
242249
],
243250
};
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
2-
require('../../modules/es.set');
2+
var parent = require('../../stable/set/difference');
33
require('../../modules/esnext.set.difference.v2');
4-
var entryUnbind = require('../../internals/entry-unbind');
54

6-
module.exports = entryUnbind('Set', 'difference');
5+
module.exports = parent;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
2-
require('../../modules/es.set');
2+
var parent = require('../../stable/set/intersection');
33
require('../../modules/esnext.set.intersection.v2');
4-
var entryUnbind = require('../../internals/entry-unbind');
54

6-
module.exports = entryUnbind('Set', 'intersection');
5+
module.exports = parent;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
2-
require('../../modules/es.set');
2+
var parent = require('../../stable/set/is-disjoint-from');
33
require('../../modules/esnext.set.is-disjoint-from.v2');
4-
var entryUnbind = require('../../internals/entry-unbind');
54

6-
module.exports = entryUnbind('Set', 'isDisjointFrom');
5+
module.exports = parent;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
2-
require('../../modules/es.set');
2+
var parent = require('../../stable/set/is-subset-of');
33
require('../../modules/esnext.set.is-subset-of.v2');
4-
var entryUnbind = require('../../internals/entry-unbind');
54

6-
module.exports = entryUnbind('Set', 'isSubsetOf');
5+
module.exports = parent;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
2-
require('../../modules/es.set');
2+
var parent = require('../../stable/set/is-superset-of');
33
require('../../modules/esnext.set.is-superset-of.v2');
4-
var entryUnbind = require('../../internals/entry-unbind');
54

6-
module.exports = entryUnbind('Set', 'isSupersetOf');
5+
module.exports = parent;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
2-
require('../../modules/es.set');
2+
var parent = require('../../stable/set/symmetric-difference');
33
require('../../modules/esnext.set.symmetric-difference.v2');
4-
var entryUnbind = require('../../internals/entry-unbind');
54

6-
module.exports = entryUnbind('Set', 'symmetricDifference');
5+
module.exports = parent;

0 commit comments

Comments
 (0)