UNPKG

@thi.ng/ecs

Version:

Entity Component System based around typed arrays & sparse sets

34 lines (33 loc) 565 B
class UnboundedCache { index; constructor() { this.index = /* @__PURE__ */ new Map(); } clear() { this.index.clear(); } release() { this.clear(); return true; } keys() { return this.index.keys(); } set(key, val) { this.index.set(key, val); return val; } get(key) { return this.index.get(key); } getSet(key, notFound) { let val = this.index.get(key); return val !== void 0 ? val : this.set(key, notFound()); } delete(key) { return this.index.delete(key); } } export { UnboundedCache };