multi-value-map
Version:
26 lines • 586 B
JavaScript
export class MultiValueWeakMap {
constructor() {
this.map = new WeakMap();
}
get(key) {
return this.map.get(key) || [];
}
push(key, value) {
const array = this.get(key);
if (!array.length) {
this.map.set(key, array);
}
array.push(value);
return this;
}
delete(key) {
return this.map.delete(key);
}
has(key) {
return this.map.has(key);
}
get [Symbol.toStringTag]() {
return this.map.toString();
}
}
//# sourceMappingURL=multi-value-weak-map.js.map