UNPKG

@knyt/luthier

Version:

A library for building standardized, type-safe native web components with full SSR and hydration support.

31 lines (30 loc) 752 B
export class ImmutableRegistry { #values; constructor(values) { this.#values = new Set(values); } /** * Returns a new PromiseRegistry instance with the added value. */ with(value) { return new ImmutableRegistry([...this.#values, value]); } /** * Returns a new PromiseRegistry instance with the removed value. */ without(value) { return new ImmutableRegistry([...this.#values].filter((p) => p !== value)); } has(value) { return this.#values.has(value); } get size() { return this.#values.size; } get hasAny() { return this.#values.size > 0; } [Symbol.iterator]() { return this.#values[Symbol.iterator](); } }