From 559081fdeeed9bddae368b71a002ff3dfb69d0ad Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sat, 30 Mar 2024 22:21:59 +0700 Subject: [PATCH] move new `Set` methods to stable ES --- README.md | 78 +++++----- packages/core-js-compat/src/data.mjs | 147 ++++++++++-------- .../src/modules-by-versions.mjs | 7 + packages/core-js/actual/set/difference.js | 5 +- packages/core-js/actual/set/intersection.js | 5 +- .../core-js/actual/set/is-disjoint-from.js | 5 +- packages/core-js/actual/set/is-subset-of.js | 5 +- packages/core-js/actual/set/is-superset-of.js | 5 +- .../actual/set/symmetric-difference.js | 5 +- packages/core-js/actual/set/union.js | 5 +- packages/core-js/es/set/difference.js | 6 + packages/core-js/es/set/index.js | 7 + packages/core-js/es/set/intersection.js | 6 + packages/core-js/es/set/is-disjoint-from.js | 6 + packages/core-js/es/set/is-subset-of.js | 6 + packages/core-js/es/set/is-superset-of.js | 6 + .../core-js/es/set/symmetric-difference.js | 6 + packages/core-js/es/set/union.js | 6 + .../core-js/modules/es.set.difference.v2.js | 10 ++ .../core-js/modules/es.set.intersection.v2.js | 16 ++ .../modules/es.set.is-disjoint-from.v2.js | 10 ++ .../core-js/modules/es.set.is-subset-of.v2.js | 10 ++ .../modules/es.set.is-superset-of.v2.js | 10 ++ .../modules/es.set.symmetric-difference.v2.js | 10 ++ packages/core-js/modules/es.set.union.v2.js | 10 ++ .../modules/esnext.set.difference.v2.js | 11 +- .../modules/esnext.set.intersection.v2.js | 17 +- .../modules/esnext.set.is-disjoint-from.v2.js | 11 +- .../modules/esnext.set.is-subset-of.v2.js | 11 +- .../modules/esnext.set.is-superset-of.v2.js | 11 +- .../esnext.set.symmetric-difference.v2.js | 11 +- .../core-js/modules/esnext.set.union.v2.js | 11 +- packages/core-js/stable/set/difference.js | 4 + packages/core-js/stable/set/intersection.js | 4 + .../core-js/stable/set/is-disjoint-from.js | 4 + packages/core-js/stable/set/is-subset-of.js | 4 + packages/core-js/stable/set/is-superset-of.js | 4 + .../stable/set/symmetric-difference.js | 4 + packages/core-js/stable/set/union.js | 4 + packages/core-js/stage/3.js | 1 - packages/core-js/stage/4.js | 1 + tests/compat/tests.js | 18 +-- tests/entries/unit.mjs | 14 +- ...set.difference.js => es.set.difference.js} | 0 ...intersection.js => es.set.intersection.js} | 0 ...int-from.js => es.set.is-disjoint-from.js} | 0 ...is-subset-of.js => es.set.is-subset-of.js} | 0 ...uperset-of.js => es.set.is-superset-of.js} | 0 ...ence.js => es.set.symmetric-difference.js} | 0 .../{esnext.set.union.js => es.set.union.js} | 0 ...set.difference.js => es.set.difference.js} | 1 + ...intersection.js => es.set.intersection.js} | 1 + ...int-from.js => es.set.is-disjoint-from.js} | 1 + ...is-subset-of.js => es.set.is-subset-of.js} | 1 + ...uperset-of.js => es.set.is-superset-of.js} | 1 + ...ence.js => es.set.symmetric-difference.js} | 1 + .../{esnext.set.union.js => es.set.union.js} | 1 + 57 files changed, 337 insertions(+), 207 deletions(-) create mode 100644 packages/core-js/es/set/difference.js create mode 100644 packages/core-js/es/set/intersection.js create mode 100644 packages/core-js/es/set/is-disjoint-from.js create mode 100644 packages/core-js/es/set/is-subset-of.js create mode 100644 packages/core-js/es/set/is-superset-of.js create mode 100644 packages/core-js/es/set/symmetric-difference.js create mode 100644 packages/core-js/es/set/union.js create mode 100644 packages/core-js/modules/es.set.difference.v2.js create mode 100644 packages/core-js/modules/es.set.intersection.v2.js create mode 100644 packages/core-js/modules/es.set.is-disjoint-from.v2.js create mode 100644 packages/core-js/modules/es.set.is-subset-of.v2.js create mode 100644 packages/core-js/modules/es.set.is-superset-of.v2.js create mode 100644 packages/core-js/modules/es.set.symmetric-difference.v2.js create mode 100644 packages/core-js/modules/es.set.union.v2.js create mode 100644 packages/core-js/stable/set/difference.js create mode 100644 packages/core-js/stable/set/intersection.js create mode 100644 packages/core-js/stable/set/is-disjoint-from.js create mode 100644 packages/core-js/stable/set/is-subset-of.js create mode 100644 packages/core-js/stable/set/is-superset-of.js create mode 100644 packages/core-js/stable/set/symmetric-difference.js create mode 100644 packages/core-js/stable/set/union.js rename tests/unit-global/{esnext.set.difference.js => es.set.difference.js} (100%) rename tests/unit-global/{esnext.set.intersection.js => es.set.intersection.js} (100%) rename tests/unit-global/{esnext.set.is-disjoint-from.js => es.set.is-disjoint-from.js} (100%) rename tests/unit-global/{esnext.set.is-subset-of.js => es.set.is-subset-of.js} (100%) rename tests/unit-global/{esnext.set.is-superset-of.js => es.set.is-superset-of.js} (100%) rename tests/unit-global/{esnext.set.symmetric-difference.js => es.set.symmetric-difference.js} (100%) rename tests/unit-global/{esnext.set.union.js => es.set.union.js} (100%) rename tests/unit-pure/{esnext.set.difference.js => es.set.difference.js} (97%) rename tests/unit-pure/{esnext.set.intersection.js => es.set.intersection.js} (98%) rename tests/unit-pure/{esnext.set.is-disjoint-from.js => es.set.is-disjoint-from.js} (98%) rename tests/unit-pure/{esnext.set.is-subset-of.js => es.set.is-subset-of.js} (98%) rename tests/unit-pure/{esnext.set.is-superset-of.js => es.set.is-superset-of.js} (98%) rename tests/unit-pure/{esnext.set.symmetric-difference.js => es.set.symmetric-difference.js} (98%) rename tests/unit-pure/{esnext.set.union.js => es.set.union.js} (97%) diff --git a/README.md b/README.md index c4ec3f2701bb..abcdfedb2305 100644 --- a/README.md +++ b/README.md @@ -154,10 +154,10 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) - [`Symbol.prototype.description`](#symbolprototypedescription) - [Well-formed `JSON.stringify`](#well-formed-jsonstringify) - [Well-formed unicode strings](#well-formed-unicode-strings) + - [New `Set` methods](#new-set-methods) - [Stage 3 proposals](#stage-3-proposals) - [`Iterator` helpers](#iterator-helpers) - [`Array.fromAsync`](#arrayfromasync) - - [New `Set` methods](#new-set-methods) - [`JSON.parse` source text access](#jsonparse-source-text-access) - [`Float16` methods](#float16-methods) - [Explicit resource management](#explicit-resource-management) @@ -1499,7 +1499,7 @@ map.get(1); // => [1, 3, 5] map.get(0); // => [2, 4] ``` #### Set[⬆](#index) -Module [`es.set`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/es.set.js). +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) ```js class Set { constructor(iterable?: Iterable): Set; @@ -1511,6 +1511,13 @@ class Set { values(): Iterator; keys(): Iterator; entries(): Iterator<[value, value]>; + difference(other: SetLike): Set; + intersection(other: SetLike): Set; + isDisjointFrom(other: SetLike): boolean; + isSubsetOf(other: SetLike): boolean; + isSupersetOf(other: SetLike): boolean; + symmetricDifference(other: SetLike): Set; + union(other: SetLike): Set; @@iterator(): Iterator; readonly attribute size: number; } @@ -1518,8 +1525,15 @@ class Set { [*CommonJS entry points:*](#commonjs-api) ``` core-js(-pure)/es|stable|actual|full/set +core-js(-pure)/es|stable|actual|full/set/difference +core-js(-pure)/es|stable|actual|full/set/intersection +core-js(-pure)/es|stable|actual|full/set/is-disjoint-from +core-js(-pure)/es|stable|actual|full/set/is-subset-of +core-js(-pure)/es|stable|actual|full/set/is-superset-of +core-js(-pure)/es|stable|actual|full/set/symmetric-difference +core-js(-pure)/es|stable|actual|full/set/union ``` -[*Examples*](https://goo.gl/bmhLwg): +[*Examples*](https://tinyurl.com/2dy5t9ey): ```js let set = new Set(['a', 'b', 'a', 'c']); set.add('d').add('b').add('e'); @@ -1542,6 +1556,14 @@ for (let [key, value] of set.entries()) { console.log(key); // => 1, 2, 3 console.log(value); // => 1, 2, 3 } + +new Set([1, 2, 3]).union(new Set([3, 4, 5])); // => Set {1, 2, 3, 4, 5} +new Set([1, 2, 3]).intersection(new Set([3, 4, 5])); // => Set {3} +new Set([1, 2, 3]).difference(new Set([3, 4, 5])); // => Set {1, 2} +new Set([1, 2, 3]).symmetricDifference(new Set([3, 4, 5])); // => Set {1, 2, 4, 5} +new Set([1, 2, 3]).isDisjointFrom(new Set([4, 5, 6])); // => true +new Set([1, 2, 3]).isSubsetOf(new Set([5, 4, 3, 2, 1])); // => true +new Set([5, 4, 3, 2, 1]).isSupersetOf(new Set([1, 2, 3])); // => true ``` #### WeakMap[⬆](#index) 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 { ```js core-js/proposals/well-formed-unicode-strings ``` +##### [New `Set` methods](https://github.com/tc39/proposal-set-methods)[⬆](#index) +```js +class Set { + difference(other: SetLike): Set; + intersection(other: SetLike): Set; + isDisjointFrom(other: SetLike): boolean; + isSubsetOf(other: SetLike): boolean; + isSupersetOf(other: SetLike): boolean; + symmetricDifference(other: SetLike): Set; + union(other: SetLike): Set; +} +``` +[*CommonJS entry points:*](#commonjs-api) +```js +core-js/proposals/set-methods-v2 +``` #### Stage 3 proposals[⬆](#index) @@ -2314,40 +2352,6 @@ core-js(-pure)/actual|full/array/from-async ```js await Array.fromAsync((async function * (){ yield * [1, 2, 3] })(), i => i * i); // => [1, 4, 9] ``` -##### [New `Set` methods](https://github.com/tc39/proposal-set-methods)[⬆](#index) -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) -```js -class Set { - difference(other: SetLike): Set; - intersection(other: SetLike): Set; - isDisjointFrom(other: SetLike): boolean; - isSubsetOf(other: SetLike): boolean; - isSupersetOf(other: SetLike): boolean; - symmetricDifference(other: SetLike): Set; - union(other: SetLike): Set; -} -``` -[*CommonJS entry points:*](#commonjs-api) -```js -core-js/proposals/set-methods-v2 -core-js(-pure)/actual|full/set/difference -core-js(-pure)/actual|full/set/intersection -core-js(-pure)/actual|full/set/is-disjoint-from -core-js(-pure)/actual|full/set/is-subset-of -core-js(-pure)/actual|full/set/is-superset-of -core-js(-pure)/actual|full/set/symmetric-difference -core-js(-pure)/actual|full/set/union -``` -[*Examples*](https://tinyurl.com/2henaoac): -```js -new Set([1, 2, 3]).union(new Set([3, 4, 5])); // => Set {1, 2, 3, 4, 5} -new Set([1, 2, 3]).intersection(new Set([3, 4, 5])); // => Set {3} -new Set([1, 2, 3]).difference(new Set([3, 4, 5])); // => Set {1, 2} -new Set([1, 2, 3]).symmetricDifference(new Set([3, 4, 5])); // => Set {1, 2, 4, 5} -new Set([1, 2, 3]).isDisjointFrom(new Set([4, 5, 6])); // => true -new Set([1, 2, 3]).isSubsetOf(new Set([5, 4, 3, 2, 1])); // => true -new Set([5, 4, 3, 2, 1]).isSupersetOf(new Set([1, 2, 3])); // => true -``` ##### [`JSON.parse` source text access](https://github.com/tc39/proposal-json-parse-with-source)[⬆](#index) 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). diff --git a/packages/core-js-compat/src/data.mjs b/packages/core-js-compat/src/data.mjs index 798f22c58979..e66d381d56f0 100644 --- a/packages/core-js-compat/src/data.mjs +++ b/packages/core-js-compat/src/data.mjs @@ -1348,6 +1348,69 @@ export const data = { rhino: '1.7.13', safari: '10.0', }, + 'es.set.difference.v2': { + bun: '1.1.1', + // v8 ~ Chrome 122 do not properly work with set-like objects + // https://bugs.chromium.org/p/v8/issues/detail?id=14559 + chrome: '123', + // safari do not properly work with set-like objects + // https://bugs.webkit.org/show_bug.cgi?id=267494 + // safari: '17.0', + }, + 'es.set.intersection.v2': { + bun: '1.1.1', + // v8 ~ Chrome 122 do not properly work with set-like objects + // https://bugs.chromium.org/p/v8/issues/detail?id=14559 + chrome: '123', + // safari do not properly work with set-like objects + // https://bugs.webkit.org/show_bug.cgi?id=267494 + // safari: '17.0', + }, + 'es.set.is-disjoint-from.v2': { + bun: '1.1.1', + // v8 ~ Chrome 122 do not properly work with set-like objects + // https://bugs.chromium.org/p/v8/issues/detail?id=14559 + chrome: '123', + // safari do not properly work with set-like objects + // https://bugs.webkit.org/show_bug.cgi?id=267494 + // safari: '17.0', + }, + 'es.set.is-subset-of.v2': { + bun: '1.1.1', + // v8 ~ Chrome 122 do not properly work with set-like objects + // https://bugs.chromium.org/p/v8/issues/detail?id=14559 + chrome: '123', + // safari do not properly work with set-like objects + // https://bugs.webkit.org/show_bug.cgi?id=267494 + // safari: '17.0', + }, + 'es.set.is-superset-of.v2': { + bun: '1.1.1', + // v8 ~ Chrome 122 do not properly work with set-like objects + // https://bugs.chromium.org/p/v8/issues/detail?id=14559 + chrome: '123', + // safari do not properly work with set-like objects + // https://bugs.webkit.org/show_bug.cgi?id=267494 + // safari: '17.0', + }, + 'es.set.symmetric-difference.v2': { + bun: '1.1.1', + // v8 ~ Chrome 122 do not properly work with set-like objects + // https://bugs.chromium.org/p/v8/issues/detail?id=14559 + chrome: '123', + // safari do not properly work with set-like objects + // https://bugs.webkit.org/show_bug.cgi?id=267494 + // safari: '17.0', + }, + 'es.set.union.v2': { + bun: '1.1.1', + // v8 ~ Chrome 122 do not properly work with set-like objects + // https://bugs.chromium.org/p/v8/issues/detail?id=14559 + chrome: '123', + // safari do not properly work with set-like objects + // https://bugs.webkit.org/show_bug.cgi?id=267494 + // safari: '17.0', + }, 'es.string.at-alternative': { chrome: '92', firefox: '90', @@ -2261,15 +2324,8 @@ export const data = { }, 'esnext.set.delete-all': { }, - 'esnext.set.difference.v2': { - // v8 ~ Chrome 122 do not properly work with set-like objects - // https://bugs.chromium.org/p/v8/issues/detail?id=14559 - chrome: '123', - bun: '1.1.1', - // safari do not properly work with set-like objects - // https://bugs.webkit.org/show_bug.cgi?id=267494 - // safari: '17.0', - }, + // TODO: Remove from `core-js@4` + 'esnext.set.difference.v2': null, // TODO: Remove from `core-js@4` 'esnext.set.difference': { }, @@ -2281,51 +2337,23 @@ export const data = { }, 'esnext.set.from': { }, - 'esnext.set.intersection.v2': { - // v8 ~ Chrome 122 do not properly work with set-like objects - // https://bugs.chromium.org/p/v8/issues/detail?id=14559 - chrome: '123', - bun: '1.1.1', - // safari do not properly work with set-like objects - // https://bugs.webkit.org/show_bug.cgi?id=267494 - // safari: '17.0', - }, + // TODO: Remove from `core-js@4` + 'esnext.set.intersection.v2': null, // TODO: Remove from `core-js@4` 'esnext.set.intersection': { }, - 'esnext.set.is-disjoint-from.v2': { - // v8 ~ Chrome 122 do not properly work with set-like objects - // https://bugs.chromium.org/p/v8/issues/detail?id=14559 - chrome: '123', - bun: '1.1.1', - // safari do not properly work with set-like objects - // https://bugs.webkit.org/show_bug.cgi?id=267494 - // safari: '17.0', - }, + // TODO: Remove from `core-js@4` + 'esnext.set.is-disjoint-from.v2': null, // TODO: Remove from `core-js@4` 'esnext.set.is-disjoint-from': { }, - 'esnext.set.is-subset-of.v2': { - // v8 ~ Chrome 122 do not properly work with set-like objects - // https://bugs.chromium.org/p/v8/issues/detail?id=14559 - chrome: '123', - bun: '1.1.1', - // safari do not properly work with set-like objects - // https://bugs.webkit.org/show_bug.cgi?id=267494 - // safari: '17.0', - }, + // TODO: Remove from `core-js@4` + 'esnext.set.is-subset-of.v2': null, // TODO: Remove from `core-js@4` 'esnext.set.is-subset-of': { }, - 'esnext.set.is-superset-of.v2': { - // v8 ~ Chrome 122 do not properly work with set-like objects - // https://bugs.chromium.org/p/v8/issues/detail?id=14559 - chrome: '123', - bun: '1.1.1', - // safari do not properly work with set-like objects - // https://bugs.webkit.org/show_bug.cgi?id=267494 - // safari: '17.0', - }, + // TODO: Remove from `core-js@4` + 'esnext.set.is-superset-of.v2': null, // TODO: Remove from `core-js@4` 'esnext.set.is-superset-of': { }, @@ -2339,27 +2367,13 @@ export const data = { }, 'esnext.set.some': { }, - 'esnext.set.symmetric-difference.v2': { - // v8 ~ Chrome 122 do not properly work with set-like objects - // https://bugs.chromium.org/p/v8/issues/detail?id=14559 - chrome: '123', - bun: '1.1.1', - // safari do not properly work with set-like objects - // https://bugs.webkit.org/show_bug.cgi?id=267494 - // safari: '17.0', - }, + // TODO: Remove from `core-js@4` + 'esnext.set.symmetric-difference.v2': null, // TODO: Remove from `core-js@4` 'esnext.set.symmetric-difference': { }, - 'esnext.set.union.v2': { - // v8 ~ Chrome 122 do not properly work with set-like objects - // https://bugs.chromium.org/p/v8/issues/detail?id=14559 - chrome: '123', - bun: '1.1.1', - // safari do not properly work with set-like objects - // https://bugs.webkit.org/show_bug.cgi?id=267494 - // safari: '17.0', - }, + // TODO: Remove from `core-js@4` + 'esnext.set.union.v2': null, // TODO: Remove from `core-js@4` 'esnext.set.union': { }, @@ -2727,6 +2741,13 @@ export const renamed = new Map([ ['esnext.promise.all-settled', 'es.promise.all-settled'], ['esnext.promise.any', 'es.promise.any'], ['esnext.promise.with-resolvers', 'es.promise.with-resolvers'], + ['esnext.set.difference.v2', 'es.set.difference.v2'], + ['esnext.set.intersection.v2', 'es.set.intersection.v2'], + ['esnext.set.is-disjoint-from.v2', 'es.set.is-disjoint-from.v2'], + ['esnext.set.is-subset-of.v2', 'es.set.is-subset-of.v2'], + ['esnext.set.is-superset-of.v2', 'es.set.is-superset-of.v2'], + ['esnext.set.symmetric-difference.v2', 'es.set.symmetric-difference.v2'], + ['esnext.set.union.v2', 'es.set.union.v2'], ['esnext.string.is-well-formed', 'es.string.is-well-formed'], ['esnext.string.match-all', 'es.string.match-all'], ['esnext.string.replace-all', 'es.string.replace-all'], diff --git a/packages/core-js-compat/src/modules-by-versions.mjs b/packages/core-js-compat/src/modules-by-versions.mjs index f9d767d25cdf..708eb4cf86b2 100644 --- a/packages/core-js-compat/src/modules-by-versions.mjs +++ b/packages/core-js-compat/src/modules-by-versions.mjs @@ -238,6 +238,13 @@ export default { 'es.array-buffer.transfer-to-fixed-length', ], 3.37: [ + 'es.set.difference.v2', + 'es.set.intersection.v2', + 'es.set.is-disjoint-from.v2', + 'es.set.is-subset-of.v2', + 'es.set.is-superset-of.v2', + 'es.set.symmetric-difference.v2', + 'es.set.union.v2', 'web.url.parse', ], }; diff --git a/packages/core-js/actual/set/difference.js b/packages/core-js/actual/set/difference.js index e5ac49660ee3..594bd7a1301c 100644 --- a/packages/core-js/actual/set/difference.js +++ b/packages/core-js/actual/set/difference.js @@ -1,6 +1,5 @@ 'use strict'; -require('../../modules/es.set'); +var parent = require('../../stable/set/difference'); require('../../modules/esnext.set.difference.v2'); -var entryUnbind = require('../../internals/entry-unbind'); -module.exports = entryUnbind('Set', 'difference'); +module.exports = parent; diff --git a/packages/core-js/actual/set/intersection.js b/packages/core-js/actual/set/intersection.js index 3d0b2383dc9f..d245fec3a0ac 100644 --- a/packages/core-js/actual/set/intersection.js +++ b/packages/core-js/actual/set/intersection.js @@ -1,6 +1,5 @@ 'use strict'; -require('../../modules/es.set'); +var parent = require('../../stable/set/intersection'); require('../../modules/esnext.set.intersection.v2'); -var entryUnbind = require('../../internals/entry-unbind'); -module.exports = entryUnbind('Set', 'intersection'); +module.exports = parent; diff --git a/packages/core-js/actual/set/is-disjoint-from.js b/packages/core-js/actual/set/is-disjoint-from.js index 24028287196b..6781d79e6970 100644 --- a/packages/core-js/actual/set/is-disjoint-from.js +++ b/packages/core-js/actual/set/is-disjoint-from.js @@ -1,6 +1,5 @@ 'use strict'; -require('../../modules/es.set'); +var parent = require('../../stable/set/is-disjoint-from'); require('../../modules/esnext.set.is-disjoint-from.v2'); -var entryUnbind = require('../../internals/entry-unbind'); -module.exports = entryUnbind('Set', 'isDisjointFrom'); +module.exports = parent; diff --git a/packages/core-js/actual/set/is-subset-of.js b/packages/core-js/actual/set/is-subset-of.js index c6e3bcddd627..96a48be9487d 100644 --- a/packages/core-js/actual/set/is-subset-of.js +++ b/packages/core-js/actual/set/is-subset-of.js @@ -1,6 +1,5 @@ 'use strict'; -require('../../modules/es.set'); +var parent = require('../../stable/set/is-subset-of'); require('../../modules/esnext.set.is-subset-of.v2'); -var entryUnbind = require('../../internals/entry-unbind'); -module.exports = entryUnbind('Set', 'isSubsetOf'); +module.exports = parent; diff --git a/packages/core-js/actual/set/is-superset-of.js b/packages/core-js/actual/set/is-superset-of.js index c79a6f329ff9..3c67563670ae 100644 --- a/packages/core-js/actual/set/is-superset-of.js +++ b/packages/core-js/actual/set/is-superset-of.js @@ -1,6 +1,5 @@ 'use strict'; -require('../../modules/es.set'); +var parent = require('../../stable/set/is-superset-of'); require('../../modules/esnext.set.is-superset-of.v2'); -var entryUnbind = require('../../internals/entry-unbind'); -module.exports = entryUnbind('Set', 'isSupersetOf'); +module.exports = parent; diff --git a/packages/core-js/actual/set/symmetric-difference.js b/packages/core-js/actual/set/symmetric-difference.js index cb9dd2ed8c7b..4efeeb38be46 100644 --- a/packages/core-js/actual/set/symmetric-difference.js +++ b/packages/core-js/actual/set/symmetric-difference.js @@ -1,6 +1,5 @@ 'use strict'; -require('../../modules/es.set'); +var parent = require('../../stable/set/symmetric-difference'); require('../../modules/esnext.set.symmetric-difference.v2'); -var entryUnbind = require('../../internals/entry-unbind'); -module.exports = entryUnbind('Set', 'symmetricDifference'); +module.exports = parent; diff --git a/packages/core-js/actual/set/union.js b/packages/core-js/actual/set/union.js index 47a01520c27a..50d0a0123c64 100644 --- a/packages/core-js/actual/set/union.js +++ b/packages/core-js/actual/set/union.js @@ -1,6 +1,5 @@ 'use strict'; -require('../../modules/es.set'); +var parent = require('../../stable/set/union'); require('../../modules/esnext.set.union.v2'); -var entryUnbind = require('../../internals/entry-unbind'); -module.exports = entryUnbind('Set', 'union'); +module.exports = parent; diff --git a/packages/core-js/es/set/difference.js b/packages/core-js/es/set/difference.js new file mode 100644 index 000000000000..cc5a1d643b28 --- /dev/null +++ b/packages/core-js/es/set/difference.js @@ -0,0 +1,6 @@ +'use strict'; +require('../../modules/es.set'); +require('../../modules/es.set.difference.v2'); +var entryUnbind = require('../../internals/entry-unbind'); + +module.exports = entryUnbind('Set', 'difference'); diff --git a/packages/core-js/es/set/index.js b/packages/core-js/es/set/index.js index b1b8f00c0e85..9a300f8fb59e 100644 --- a/packages/core-js/es/set/index.js +++ b/packages/core-js/es/set/index.js @@ -2,6 +2,13 @@ require('../../modules/es.array.iterator'); require('../../modules/es.object.to-string'); require('../../modules/es.set'); +require('../../modules/es.set.difference.v2'); +require('../../modules/es.set.intersection.v2'); +require('../../modules/es.set.is-disjoint-from.v2'); +require('../../modules/es.set.is-subset-of.v2'); +require('../../modules/es.set.is-superset-of.v2'); +require('../../modules/es.set.symmetric-difference.v2'); +require('../../modules/es.set.union.v2'); require('../../modules/es.string.iterator'); var path = require('../../internals/path'); diff --git a/packages/core-js/es/set/intersection.js b/packages/core-js/es/set/intersection.js new file mode 100644 index 000000000000..8c2b7a1c24ed --- /dev/null +++ b/packages/core-js/es/set/intersection.js @@ -0,0 +1,6 @@ +'use strict'; +require('../../modules/es.set'); +require('../../modules/es.set.intersection.v2'); +var entryUnbind = require('../../internals/entry-unbind'); + +module.exports = entryUnbind('Set', 'intersection'); diff --git a/packages/core-js/es/set/is-disjoint-from.js b/packages/core-js/es/set/is-disjoint-from.js new file mode 100644 index 000000000000..1888869649fc --- /dev/null +++ b/packages/core-js/es/set/is-disjoint-from.js @@ -0,0 +1,6 @@ +'use strict'; +require('../../modules/es.set'); +require('../../modules/es.set.is-disjoint-from.v2'); +var entryUnbind = require('../../internals/entry-unbind'); + +module.exports = entryUnbind('Set', 'isDisjointFrom'); diff --git a/packages/core-js/es/set/is-subset-of.js b/packages/core-js/es/set/is-subset-of.js new file mode 100644 index 000000000000..242f71740456 --- /dev/null +++ b/packages/core-js/es/set/is-subset-of.js @@ -0,0 +1,6 @@ +'use strict'; +require('../../modules/es.set'); +require('../../modules/es.set.is-subset-of.v2'); +var entryUnbind = require('../../internals/entry-unbind'); + +module.exports = entryUnbind('Set', 'isSubsetOf'); diff --git a/packages/core-js/es/set/is-superset-of.js b/packages/core-js/es/set/is-superset-of.js new file mode 100644 index 000000000000..ee81cfb46e34 --- /dev/null +++ b/packages/core-js/es/set/is-superset-of.js @@ -0,0 +1,6 @@ +'use strict'; +require('../../modules/es.set'); +require('../../modules/es.set.is-superset-of.v2'); +var entryUnbind = require('../../internals/entry-unbind'); + +module.exports = entryUnbind('Set', 'isSupersetOf'); diff --git a/packages/core-js/es/set/symmetric-difference.js b/packages/core-js/es/set/symmetric-difference.js new file mode 100644 index 000000000000..60fbf7b5df39 --- /dev/null +++ b/packages/core-js/es/set/symmetric-difference.js @@ -0,0 +1,6 @@ +'use strict'; +require('../../modules/es.set'); +require('../../modules/es.set.symmetric-difference.v2'); +var entryUnbind = require('../../internals/entry-unbind'); + +module.exports = entryUnbind('Set', 'symmetricDifference'); diff --git a/packages/core-js/es/set/union.js b/packages/core-js/es/set/union.js new file mode 100644 index 000000000000..d5d7516d7091 --- /dev/null +++ b/packages/core-js/es/set/union.js @@ -0,0 +1,6 @@ +'use strict'; +require('../../modules/es.set'); +require('../../modules/es.set.union.v2'); +var entryUnbind = require('../../internals/entry-unbind'); + +module.exports = entryUnbind('Set', 'union'); diff --git a/packages/core-js/modules/es.set.difference.v2.js b/packages/core-js/modules/es.set.difference.v2.js new file mode 100644 index 000000000000..074b3911311f --- /dev/null +++ b/packages/core-js/modules/es.set.difference.v2.js @@ -0,0 +1,10 @@ +'use strict'; +var $ = require('../internals/export'); +var difference = require('../internals/set-difference'); +var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); + +// `Set.prototype.difference` method +// https://github.com/tc39/proposal-set-methods +$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('difference') }, { + difference: difference +}); diff --git a/packages/core-js/modules/es.set.intersection.v2.js b/packages/core-js/modules/es.set.intersection.v2.js new file mode 100644 index 000000000000..226d7ee97cfa --- /dev/null +++ b/packages/core-js/modules/es.set.intersection.v2.js @@ -0,0 +1,16 @@ +'use strict'; +var $ = require('../internals/export'); +var fails = require('../internals/fails'); +var intersection = require('../internals/set-intersection'); +var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); + +var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () { + // eslint-disable-next-line es/no-array-from, es/no-set -- testing + return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) !== '3,2'; +}); + +// `Set.prototype.intersection` method +// https://github.com/tc39/proposal-set-methods +$({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { + intersection: intersection +}); diff --git a/packages/core-js/modules/es.set.is-disjoint-from.v2.js b/packages/core-js/modules/es.set.is-disjoint-from.v2.js new file mode 100644 index 000000000000..f9139e48514e --- /dev/null +++ b/packages/core-js/modules/es.set.is-disjoint-from.v2.js @@ -0,0 +1,10 @@ +'use strict'; +var $ = require('../internals/export'); +var isDisjointFrom = require('../internals/set-is-disjoint-from'); +var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); + +// `Set.prototype.isDisjointFrom` method +// https://github.com/tc39/proposal-set-methods +$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isDisjointFrom') }, { + isDisjointFrom: isDisjointFrom +}); diff --git a/packages/core-js/modules/es.set.is-subset-of.v2.js b/packages/core-js/modules/es.set.is-subset-of.v2.js new file mode 100644 index 000000000000..cbdf60d09f9a --- /dev/null +++ b/packages/core-js/modules/es.set.is-subset-of.v2.js @@ -0,0 +1,10 @@ +'use strict'; +var $ = require('../internals/export'); +var isSubsetOf = require('../internals/set-is-subset-of'); +var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); + +// `Set.prototype.isSubsetOf` method +// https://github.com/tc39/proposal-set-methods +$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSubsetOf') }, { + isSubsetOf: isSubsetOf +}); diff --git a/packages/core-js/modules/es.set.is-superset-of.v2.js b/packages/core-js/modules/es.set.is-superset-of.v2.js new file mode 100644 index 000000000000..af2c8229a68d --- /dev/null +++ b/packages/core-js/modules/es.set.is-superset-of.v2.js @@ -0,0 +1,10 @@ +'use strict'; +var $ = require('../internals/export'); +var isSupersetOf = require('../internals/set-is-superset-of'); +var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); + +// `Set.prototype.isSupersetOf` method +// https://github.com/tc39/proposal-set-methods +$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSupersetOf') }, { + isSupersetOf: isSupersetOf +}); diff --git a/packages/core-js/modules/es.set.symmetric-difference.v2.js b/packages/core-js/modules/es.set.symmetric-difference.v2.js new file mode 100644 index 000000000000..b16890f515a8 --- /dev/null +++ b/packages/core-js/modules/es.set.symmetric-difference.v2.js @@ -0,0 +1,10 @@ +'use strict'; +var $ = require('../internals/export'); +var symmetricDifference = require('../internals/set-symmetric-difference'); +var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); + +// `Set.prototype.symmetricDifference` method +// https://github.com/tc39/proposal-set-methods +$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('symmetricDifference') }, { + symmetricDifference: symmetricDifference +}); diff --git a/packages/core-js/modules/es.set.union.v2.js b/packages/core-js/modules/es.set.union.v2.js new file mode 100644 index 000000000000..fcfa481ee237 --- /dev/null +++ b/packages/core-js/modules/es.set.union.v2.js @@ -0,0 +1,10 @@ +'use strict'; +var $ = require('../internals/export'); +var union = require('../internals/set-union'); +var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); + +// `Set.prototype.union` method +// https://github.com/tc39/proposal-set-methods +$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('union') }, { + union: union +}); diff --git a/packages/core-js/modules/esnext.set.difference.v2.js b/packages/core-js/modules/esnext.set.difference.v2.js index 074b3911311f..4fe7c7d50da2 100644 --- a/packages/core-js/modules/esnext.set.difference.v2.js +++ b/packages/core-js/modules/esnext.set.difference.v2.js @@ -1,10 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var difference = require('../internals/set-difference'); -var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); - -// `Set.prototype.difference` method -// https://github.com/tc39/proposal-set-methods -$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('difference') }, { - difference: difference -}); +// TODO: Remove from `core-js@4` +require('../modules/es.set.difference.v2'); diff --git a/packages/core-js/modules/esnext.set.intersection.v2.js b/packages/core-js/modules/esnext.set.intersection.v2.js index 226d7ee97cfa..c417a811e850 100644 --- a/packages/core-js/modules/esnext.set.intersection.v2.js +++ b/packages/core-js/modules/esnext.set.intersection.v2.js @@ -1,16 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var fails = require('../internals/fails'); -var intersection = require('../internals/set-intersection'); -var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); - -var INCORRECT = !setMethodAcceptSetLike('intersection') || fails(function () { - // eslint-disable-next-line es/no-array-from, es/no-set -- testing - return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) !== '3,2'; -}); - -// `Set.prototype.intersection` method -// https://github.com/tc39/proposal-set-methods -$({ target: 'Set', proto: true, real: true, forced: INCORRECT }, { - intersection: intersection -}); +// TODO: Remove from `core-js@4` +require('../modules/es.set.intersection.v2'); diff --git a/packages/core-js/modules/esnext.set.is-disjoint-from.v2.js b/packages/core-js/modules/esnext.set.is-disjoint-from.v2.js index f9139e48514e..1aec2f8018b4 100644 --- a/packages/core-js/modules/esnext.set.is-disjoint-from.v2.js +++ b/packages/core-js/modules/esnext.set.is-disjoint-from.v2.js @@ -1,10 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var isDisjointFrom = require('../internals/set-is-disjoint-from'); -var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); - -// `Set.prototype.isDisjointFrom` method -// https://github.com/tc39/proposal-set-methods -$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isDisjointFrom') }, { - isDisjointFrom: isDisjointFrom -}); +// TODO: Remove from `core-js@4` +require('../modules/es.set.is-disjoint-from.v2'); diff --git a/packages/core-js/modules/esnext.set.is-subset-of.v2.js b/packages/core-js/modules/esnext.set.is-subset-of.v2.js index cbdf60d09f9a..a89f2667d620 100644 --- a/packages/core-js/modules/esnext.set.is-subset-of.v2.js +++ b/packages/core-js/modules/esnext.set.is-subset-of.v2.js @@ -1,10 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var isSubsetOf = require('../internals/set-is-subset-of'); -var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); - -// `Set.prototype.isSubsetOf` method -// https://github.com/tc39/proposal-set-methods -$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSubsetOf') }, { - isSubsetOf: isSubsetOf -}); +// TODO: Remove from `core-js@4` +require('../modules/es.set.is-subset-of.v2'); diff --git a/packages/core-js/modules/esnext.set.is-superset-of.v2.js b/packages/core-js/modules/esnext.set.is-superset-of.v2.js index af2c8229a68d..c539c66f48ac 100644 --- a/packages/core-js/modules/esnext.set.is-superset-of.v2.js +++ b/packages/core-js/modules/esnext.set.is-superset-of.v2.js @@ -1,10 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var isSupersetOf = require('../internals/set-is-superset-of'); -var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); - -// `Set.prototype.isSupersetOf` method -// https://github.com/tc39/proposal-set-methods -$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('isSupersetOf') }, { - isSupersetOf: isSupersetOf -}); +// TODO: Remove from `core-js@4` +require('../modules/es.set.is-superset-of.v2'); diff --git a/packages/core-js/modules/esnext.set.symmetric-difference.v2.js b/packages/core-js/modules/esnext.set.symmetric-difference.v2.js index b16890f515a8..0d1f18a56547 100644 --- a/packages/core-js/modules/esnext.set.symmetric-difference.v2.js +++ b/packages/core-js/modules/esnext.set.symmetric-difference.v2.js @@ -1,10 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var symmetricDifference = require('../internals/set-symmetric-difference'); -var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); - -// `Set.prototype.symmetricDifference` method -// https://github.com/tc39/proposal-set-methods -$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('symmetricDifference') }, { - symmetricDifference: symmetricDifference -}); +// TODO: Remove from `core-js@4` +require('../modules/es.set.symmetric-difference.v2'); diff --git a/packages/core-js/modules/esnext.set.union.v2.js b/packages/core-js/modules/esnext.set.union.v2.js index fcfa481ee237..cd5c93f3fba4 100644 --- a/packages/core-js/modules/esnext.set.union.v2.js +++ b/packages/core-js/modules/esnext.set.union.v2.js @@ -1,10 +1,3 @@ 'use strict'; -var $ = require('../internals/export'); -var union = require('../internals/set-union'); -var setMethodAcceptSetLike = require('../internals/set-method-accept-set-like'); - -// `Set.prototype.union` method -// https://github.com/tc39/proposal-set-methods -$({ target: 'Set', proto: true, real: true, forced: !setMethodAcceptSetLike('union') }, { - union: union -}); +// TODO: Remove from `core-js@4` +require('../modules/es.set.union.v2'); diff --git a/packages/core-js/stable/set/difference.js b/packages/core-js/stable/set/difference.js new file mode 100644 index 000000000000..c98809197b9f --- /dev/null +++ b/packages/core-js/stable/set/difference.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/set/difference'); + +module.exports = parent; diff --git a/packages/core-js/stable/set/intersection.js b/packages/core-js/stable/set/intersection.js new file mode 100644 index 000000000000..5791c5b1f7b0 --- /dev/null +++ b/packages/core-js/stable/set/intersection.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/set/intersection'); + +module.exports = parent; diff --git a/packages/core-js/stable/set/is-disjoint-from.js b/packages/core-js/stable/set/is-disjoint-from.js new file mode 100644 index 000000000000..fa2566263bd4 --- /dev/null +++ b/packages/core-js/stable/set/is-disjoint-from.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/set/is-disjoint-from'); + +module.exports = parent; diff --git a/packages/core-js/stable/set/is-subset-of.js b/packages/core-js/stable/set/is-subset-of.js new file mode 100644 index 000000000000..39834993164c --- /dev/null +++ b/packages/core-js/stable/set/is-subset-of.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/set/is-subset-of'); + +module.exports = parent; diff --git a/packages/core-js/stable/set/is-superset-of.js b/packages/core-js/stable/set/is-superset-of.js new file mode 100644 index 000000000000..c0cddad8de42 --- /dev/null +++ b/packages/core-js/stable/set/is-superset-of.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/set/is-superset-of'); + +module.exports = parent; diff --git a/packages/core-js/stable/set/symmetric-difference.js b/packages/core-js/stable/set/symmetric-difference.js new file mode 100644 index 000000000000..ab6b27b2d2bd --- /dev/null +++ b/packages/core-js/stable/set/symmetric-difference.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/set/symmetric-difference'); + +module.exports = parent; diff --git a/packages/core-js/stable/set/union.js b/packages/core-js/stable/set/union.js new file mode 100644 index 000000000000..5d7ece276dbd --- /dev/null +++ b/packages/core-js/stable/set/union.js @@ -0,0 +1,4 @@ +'use strict'; +var parent = require('../../es/set/union'); + +module.exports = parent; diff --git a/packages/core-js/stage/3.js b/packages/core-js/stage/3.js index 0139995c1632..3556c457f3cb 100644 --- a/packages/core-js/stage/3.js +++ b/packages/core-js/stage/3.js @@ -8,7 +8,6 @@ require('../proposals/explicit-resource-management'); require('../proposals/float16'); require('../proposals/iterator-helpers-stage-3-2'); require('../proposals/json-parse-with-source'); -require('../proposals/set-methods-v2'); // TODO: Obsolete versions, remove from `core-js@4` require('../proposals/array-grouping-stage-3'); require('../proposals/array-grouping-stage-3-2'); diff --git a/packages/core-js/stage/4.js b/packages/core-js/stage/4.js index a3b129992211..f1c922ae9621 100644 --- a/packages/core-js/stage/4.js +++ b/packages/core-js/stage/4.js @@ -11,6 +11,7 @@ require('../proposals/promise-all-settled'); require('../proposals/promise-any'); require('../proposals/promise-with-resolvers'); require('../proposals/relative-indexing-method'); +require('../proposals/set-methods-v2'); require('../proposals/string-match-all'); require('../proposals/string-replace-all-stage-4'); require('../proposals/well-formed-unicode-strings'); diff --git a/tests/compat/tests.js b/tests/compat/tests.js index 274bb99e7a58..e7e215b06a0f 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -1135,6 +1135,15 @@ GLOBAL.tests = { && set.has(0) && set[Symbol.toStringTag]; }], + 'es.set.difference.v2': createSetMethodTest('difference'), + 'es.set.intersection.v2': [createSetMethodTest('intersection'), function () { + return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) === '3,2'; + }], + 'es.set.is-disjoint-from.v2': createSetMethodTest('isDisjointFrom'), + 'es.set.is-subset-of.v2': createSetMethodTest('isSubsetOf'), + 'es.set.is-superset-of.v2': createSetMethodTest('isSupersetOf'), + 'es.set.symmetric-difference.v2': createSetMethodTest('symmetricDifference'), + 'es.set.union.v2': createSetMethodTest('union'), 'es.string.at-alternative': function () { return '𠮷'.at(-2) === '\uD842'; }, @@ -1758,7 +1767,6 @@ GLOBAL.tests = { 'esnext.set.delete-all': function () { return Set.prototype.deleteAll; }, - 'esnext.set.difference.v2': createSetMethodTest('difference'), 'esnext.set.every': function () { return Set.prototype.every; }, @@ -1771,12 +1779,6 @@ GLOBAL.tests = { 'esnext.set.from': function () { return Set.from; }, - 'esnext.set.intersection.v2': [createSetMethodTest('intersection'), function () { - return String(Array.from(new Set([1, 2, 3]).intersection(new Set([3, 2])))) === '3,2'; - }], - 'esnext.set.is-disjoint-from.v2': createSetMethodTest('isDisjointFrom'), - 'esnext.set.is-subset-of.v2': createSetMethodTest('isSubsetOf'), - 'esnext.set.is-superset-of.v2': createSetMethodTest('isSupersetOf'), 'esnext.set.join': function () { return Set.prototype.join; }, @@ -1792,8 +1794,6 @@ GLOBAL.tests = { 'esnext.set.some': function () { return Set.prototype.some; }, - 'esnext.set.symmetric-difference.v2': createSetMethodTest('symmetricDifference'), - 'esnext.set.union.v2': createSetMethodTest('union'), 'esnext.string.code-points': function () { return String.prototype.codePoints; }, diff --git a/tests/entries/unit.mjs b/tests/entries/unit.mjs index 07240cffb103..0931e76123a5 100644 --- a/tests/entries/unit.mjs +++ b/tests/entries/unit.mjs @@ -316,6 +316,13 @@ for (PATH of ['core-js-pure', 'core-js']) { ok(new Set([1, 2, 3, 2, 1]).size === 3); ok(new WeakMap([[O = {}, 42]]).get(O) === 42); ok(new WeakSet([O = {}]).has(O)); + ok(load(NS, 'set/difference')(new Set([1, 2, 3]), new Set([3, 4, 5])).size === 2); + ok(load(NS, 'set/intersection')(new Set([1, 2, 3]), new Set([1, 3, 4])).size === 2); + ok(load(NS, 'set/is-disjoint-from')(new Set([1, 2, 3]), new Set([4, 5, 6]))); + ok(load(NS, 'set/is-subset-of')(new Set([1, 2, 3]), new Set([1, 2, 3, 4]))); + ok(load(NS, 'set/is-superset-of')(new Set([1, 2, 3, 4]), new Set([1, 2, 3]))); + ok(load(NS, 'set/symmetric-difference')(new Set([1, 2, 3]), new Set([3, 4, 5])).size === 4); + ok(load(NS, 'set/union')(new Set([1, 2, 3]), new Set([3, 4, 5])).size === 5); const Promise = load(NS, 'promise'); ok('then' in Promise.prototype); ok(load(NS, 'promise/all-settled')([1, 2, 3]) instanceof Promise); @@ -695,13 +702,6 @@ for (PATH of ['core-js-pure', 'core-js']) { ok(load(NS, 'json/parse')('[42]', (key, value, { source }) => typeof value == 'number' ? source + source : value)[0] === '4242'); ok(typeof load(NS, 'json/raw-json')(42) == 'object'); ok(load(NS, 'math/f16round')(1.337) === 1.3369140625); - ok(load(NS, 'set/difference')(new Set([1, 2, 3]), new Set([3, 4, 5])).size === 2); - ok(load(NS, 'set/intersection')(new Set([1, 2, 3]), new Set([1, 3, 4])).size === 2); - ok(load(NS, 'set/is-disjoint-from')(new Set([1, 2, 3]), new Set([4, 5, 6]))); - ok(load(NS, 'set/is-subset-of')(new Set([1, 2, 3]), new Set([1, 2, 3, 4]))); - ok(load(NS, 'set/is-superset-of')(new Set([1, 2, 3, 4]), new Set([1, 2, 3]))); - ok(load(NS, 'set/symmetric-difference')(new Set([1, 2, 3]), new Set([3, 4, 5])).size === 4); - ok(load(NS, 'set/union')(new Set([1, 2, 3]), new Set([3, 4, 5])).size === 5); ok(load(NS, 'symbol/dispose')); ok(load(NS, 'symbol/metadata')); ok(new (load(NS, 'suppressed-error'))(1, 2).suppressed === 2); diff --git a/tests/unit-global/esnext.set.difference.js b/tests/unit-global/es.set.difference.js similarity index 100% rename from tests/unit-global/esnext.set.difference.js rename to tests/unit-global/es.set.difference.js diff --git a/tests/unit-global/esnext.set.intersection.js b/tests/unit-global/es.set.intersection.js similarity index 100% rename from tests/unit-global/esnext.set.intersection.js rename to tests/unit-global/es.set.intersection.js diff --git a/tests/unit-global/esnext.set.is-disjoint-from.js b/tests/unit-global/es.set.is-disjoint-from.js similarity index 100% rename from tests/unit-global/esnext.set.is-disjoint-from.js rename to tests/unit-global/es.set.is-disjoint-from.js diff --git a/tests/unit-global/esnext.set.is-subset-of.js b/tests/unit-global/es.set.is-subset-of.js similarity index 100% rename from tests/unit-global/esnext.set.is-subset-of.js rename to tests/unit-global/es.set.is-subset-of.js diff --git a/tests/unit-global/esnext.set.is-superset-of.js b/tests/unit-global/es.set.is-superset-of.js similarity index 100% rename from tests/unit-global/esnext.set.is-superset-of.js rename to tests/unit-global/es.set.is-superset-of.js diff --git a/tests/unit-global/esnext.set.symmetric-difference.js b/tests/unit-global/es.set.symmetric-difference.js similarity index 100% rename from tests/unit-global/esnext.set.symmetric-difference.js rename to tests/unit-global/es.set.symmetric-difference.js diff --git a/tests/unit-global/esnext.set.union.js b/tests/unit-global/es.set.union.js similarity index 100% rename from tests/unit-global/esnext.set.union.js rename to tests/unit-global/es.set.union.js diff --git a/tests/unit-pure/esnext.set.difference.js b/tests/unit-pure/es.set.difference.js similarity index 97% rename from tests/unit-pure/esnext.set.difference.js rename to tests/unit-pure/es.set.difference.js index e1235022fe4b..1d9d572bc1fd 100644 --- a/tests/unit-pure/esnext.set.difference.js +++ b/tests/unit-pure/es.set.difference.js @@ -1,6 +1,7 @@ import { createIterable, createSetLike } from '../helpers/helpers.js'; import from from 'core-js-pure/es/array/from'; +// TODO: use /es/ in core-js@4 import Set from 'core-js-pure/full/set'; QUnit.test('Set#difference', assert => { diff --git a/tests/unit-pure/esnext.set.intersection.js b/tests/unit-pure/es.set.intersection.js similarity index 98% rename from tests/unit-pure/esnext.set.intersection.js rename to tests/unit-pure/es.set.intersection.js index 68b1875b88b3..82193f231407 100644 --- a/tests/unit-pure/esnext.set.intersection.js +++ b/tests/unit-pure/es.set.intersection.js @@ -1,6 +1,7 @@ import { createIterable, createSetLike } from '../helpers/helpers.js'; import from from 'core-js-pure/es/array/from'; +// TODO: use /es/ in core-js@4 import Set from 'core-js-pure/full/set'; QUnit.test('Set#intersection', assert => { diff --git a/tests/unit-pure/esnext.set.is-disjoint-from.js b/tests/unit-pure/es.set.is-disjoint-from.js similarity index 98% rename from tests/unit-pure/esnext.set.is-disjoint-from.js rename to tests/unit-pure/es.set.is-disjoint-from.js index 70d64168e177..79342ead7c6c 100644 --- a/tests/unit-pure/esnext.set.is-disjoint-from.js +++ b/tests/unit-pure/es.set.is-disjoint-from.js @@ -1,5 +1,6 @@ import { createIterable, createSetLike } from '../helpers/helpers.js'; +// TODO: use /es/ in core-js@4 import Set from 'core-js-pure/full/set'; QUnit.test('Set#isDisjointFrom', assert => { diff --git a/tests/unit-pure/esnext.set.is-subset-of.js b/tests/unit-pure/es.set.is-subset-of.js similarity index 98% rename from tests/unit-pure/esnext.set.is-subset-of.js rename to tests/unit-pure/es.set.is-subset-of.js index 190f22fecd27..4378207a0a29 100644 --- a/tests/unit-pure/esnext.set.is-subset-of.js +++ b/tests/unit-pure/es.set.is-subset-of.js @@ -1,5 +1,6 @@ import { createIterable, createSetLike } from '../helpers/helpers.js'; +// TODO: use /es/ in core-js@4 import Set from 'core-js-pure/full/set'; QUnit.test('Set#isSubsetOf', assert => { diff --git a/tests/unit-pure/esnext.set.is-superset-of.js b/tests/unit-pure/es.set.is-superset-of.js similarity index 98% rename from tests/unit-pure/esnext.set.is-superset-of.js rename to tests/unit-pure/es.set.is-superset-of.js index 20dd20e91bcb..8cdc987abb9e 100644 --- a/tests/unit-pure/esnext.set.is-superset-of.js +++ b/tests/unit-pure/es.set.is-superset-of.js @@ -1,5 +1,6 @@ import { createIterable, createSetLike } from '../helpers/helpers.js'; +// TODO: use /es/ in core-js@4 import Set from 'core-js-pure/full/set'; QUnit.test('Set#isSupersetOf', assert => { diff --git a/tests/unit-pure/esnext.set.symmetric-difference.js b/tests/unit-pure/es.set.symmetric-difference.js similarity index 98% rename from tests/unit-pure/esnext.set.symmetric-difference.js rename to tests/unit-pure/es.set.symmetric-difference.js index 6920e0f39b54..bea6ab58ae84 100644 --- a/tests/unit-pure/esnext.set.symmetric-difference.js +++ b/tests/unit-pure/es.set.symmetric-difference.js @@ -1,6 +1,7 @@ import { createIterable, createSetLike } from '../helpers/helpers.js'; import from from 'core-js-pure/es/array/from'; +// TODO: use /es/ in core-js@4 import Set from 'core-js-pure/full/set'; QUnit.test('Set#symmetricDifference', assert => { diff --git a/tests/unit-pure/esnext.set.union.js b/tests/unit-pure/es.set.union.js similarity index 97% rename from tests/unit-pure/esnext.set.union.js rename to tests/unit-pure/es.set.union.js index c3cb730c3c9e..5274b3213923 100644 --- a/tests/unit-pure/esnext.set.union.js +++ b/tests/unit-pure/es.set.union.js @@ -1,6 +1,7 @@ import { createIterable, createSetLike } from '../helpers/helpers.js'; import from from 'core-js-pure/es/array/from'; +// TODO: use /es/ in core-js@4 import Set from 'core-js-pure/full/set'; QUnit.test('Set#union', assert => {