New Set methods
Less than 1 minute
New Set
methods
Modules
esnext.set.difference
esnext.set.intersection
esnext.set.is-disjoint-from
esnext.set.is-subset-of
esnext.set.is-superset-of
esnext.set.symmetric-difference
esnext.set.union
Types
interface Set<T> {
difference(other: SetLike<T>): Set<T>;
intersection(other: SetLike<T>): Set<T>;
isDisjointFrom<U>(other: SetLike<U>): boolean;
isSubsetOf<U>(other: SetLike<U>): boolean;
isSupersetOf<U>(other: SetLike<U>): boolean;
symmetricDifference(other: SetLike<T>): Set<T>;
union(other: SetLike<T>): Set<T>;
}
interface SetLike<T> {
has(value: T): boolean;
keys(): IterableIterator<T>;
readonly size: number;
}
Entry points
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
Example
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