// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set export const isSuperset = (set: Set, subset: Set): boolean => { for (const elem of subset) { if (!set.has(elem)) { return false; } } return true; }; export const union = (setA: Set, setB: Set): Set => { const _union = new Set(setA); for (const elem of setB) { _union.add(elem); } return _union; }; export const intersection = (setA: Set, setB: Set): Set => { const _intersection: Set = new Set(); for (const elem of setB) { if (setA.has(elem)) { _intersection.add(elem); } } return _intersection; }; export const symmetricDifference = (setA: Set, setB: Set): Set => { const _difference = new Set(setA); for (const elem of setB) { if (_difference.has(elem)) { _difference.delete(elem); } else { _difference.add(elem); } } return _difference; }; export const difference = (setA: Set, setB: Set): Set => { const _difference = new Set(setA); for (const elem of setB) { _difference.delete(elem); } return _difference; };