UNPKG

@nodescript/core

Version:

Visual programming language for Browser and Node

35 lines 760 B
export class MultiMap { constructor() { this.map = new Map(); } add(key, value) { const set = this.map.get(key) ?? new Set(); set.add(value); this.map.set(key, set); } get(key) { return this.map.get(key) ?? new Set(); } delete(key, value) { const set = this.map.get(key); return set ? set.delete(value) : false; } deleteAll(key) { this.map.delete(key); } deleteValue(value) { for (const g of this.groups()) { g.delete(value); } } clear() { this.map.clear(); } keys() { return this.map.keys(); } groups() { return this.map.values(); } } //# sourceMappingURL=multimap.js.map