UNPKG

tc39-weakrefs-shim

Version:
36 lines 808 B
import { combine } from "./iterable.js"; export function intersects(a, b) { if (a.size > b.size) [b, a] = [a, b]; for (const elem of a) { if (b.has(elem)) return true; } return false; } export function difference(a, b) { let res; if (a.size <= b.size) { res = new Set(); for (const info of a) { if (!b.has(info)) res.add(info); } } else { res = new Set(a); remove(res, b); } return res; } export function merge(dest, ...iterables) { for (const item of combine(...iterables)) { dest.add(item); } } export function remove(dest, ...iterables) { for (const item of combine(...iterables)) { dest.delete(item); } } //# sourceMappingURL=set.js.map