UNPKG

@alexaegis/advent-of-code-lib

Version:
25 lines (24 loc) 482 B
const addAllToSet = (items, set = /* @__PURE__ */ new Set()) => { for (const item of items) { set.add(item); } return set; }; Set.prototype.valueArray = function() { return [...this.values()]; }; Set.prototype.addAll = function(items) { return addAllToSet(items, this); }; Set.prototype.flip = function(item) { const hasItem = this.has(item); if (hasItem) { this.delete(item); } else { this.add(item); } return !hasItem; }; export { addAllToSet };