UNPKG

graph-builder

Version:

A graph builder library for modeling abstract graph structures.

33 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Sets; (function (Sets) { /** * Returns an unmodifiable <b>view</b> of the difference of two sets. The returned set contains * all elements that are contained by `set1` and not contained by `set2`. `set2` * may also contain elements not present in `set1`; these are simply ignored. The iteration * order of the returned set matches that of `set1`. * * <p>Results are undefined if `set1` and `set2` are sets based on different * equivalence relations (as `HashSet`, `TreeSet`, and the keySet of an * `IdentityHashMap` all are). */ Sets.difference = (set1, set2) => { const newSet = new Set(Array.from(set1)); set2.forEach((value) => { newSet.delete(value); }); return newSet; }; Sets.equals = (a, b) => { if (a.size !== b.size) return false; for (let x of a) { if (!b.has(x)) { return false; } } return true; }; })(Sets = exports.Sets || (exports.Sets = {})); //# sourceMappingURL=Sets.js.map