UNPKG

@benev/slate

Version:
40 lines 1 kB
export class MapG extends Map { static require(map, key) { const value = map.get(key); if (value === undefined) throw new Error(`required key not found: "${key}"`); return value; } static guarantee(map, key, make) { let value = map.get(key); if (value === undefined) { value = make(); map.set(key, value); } return value; } array() { return [...this]; } require(key) { return MapG.require(this, key); } guarantee(key, make) { return MapG.guarantee(this, key, make); } } export class Pool extends MapG { got(value) { return this.has(value.id); } add(value) { this.set(value.id, value); return value; } remove(value) { return this.delete(value.id); } } /** @deprecated renamed to `MapG`, to avoid confusion with vectors like Vec2 */ export const Map2 = MapG; //# sourceMappingURL=map-g.js.map