Skip to main content
This release is 10 versions behind 0.6.7 — the latest version of @azuryth/azuryth-core. Jump to latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
29%
Published
3 months ago (0.5.0)
export type JsonValue = | string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }; export type JsonObject = {[key: string]: JsonValue}; export class ComponentStore<T> { private components: Map<string, T> constructor(components: Map<string, T> = new Map()) { this.components = components; } hasComponent(key: string): boolean { return this.components.has(key); } setComponent(key: string, val: T) { this.components.set(key, val); } removeComponent(key: string) { this.components.delete(key); } getComponent(key: string): T | undefined { return this.components.get(key); } entries(): IterableIterator<[string, T]> { return this.components.entries(); } count(): number { return this.components.size } jsonBlob(): JsonObject { const returnData: JsonObject = {}; for (const [key, val] of this.components) { returnData[key] = val as JsonValue; } return returnData; } }