// NOTE: The following Set utils have been added here, to easily determine where they are used. // They should be replaced with native Set operations, when they are added to the language. // Proposal reference: https://github.com/tc39/proposal-set-methods export const setUnion = (...sets: Set[]): Set => { const union = new Set(sets[0]); for (const set of sets.slice(1)) { for (const element of set) { union.add(element); } } return union; }; export const setDifference = (setA: Set, ...sets: Set[]): Set => { const difference = new Set(setA); for (const set of sets) { for (const element of set) { difference.delete(element); } } return difference; }; export const setIsSuperset = (set: Set, subset: Set): boolean => { for (const element of subset) { if (!set.has(element)) { return false; } } return true; }; export const setIsEqual = (setA: Set, setB: Set): boolean => { return setA.size === setB.size && setIsSuperset(setA, setB); };