immutable-plugin-system - v0.3.0
    Preparing search index...

    Class ImmutableEntityCollection<K, E>

    Implementation of immutable entity collections that provide convenient iteration methods. Wraps Map<K, E[]> functionality with additional utility methods for working with entities. Tracks which plugin each entity came from for proper attribution.

    Type Parameters

    • K extends string | symbol

      The key type, must extend PropertyKey

    • E

      The entity type

    Index

    Constructors

    Accessors

    Methods

    • Makes the collection iterable over individual entities with metadata. Each iteration yields a tuple of [entity, key, pluginURN].

      Returns Iterator<[E, K, string]>

      Iterator yielding [entity, key, pluginURN] tuples

    • Returns an iterator over all key-entity array pairs.

      Returns IterableIterator<[K, E[]]>

      Iterator yielding [key, entities[]] tuples

    • Flattens all entities into a single array with metadata. Each entity is returned as a tuple with the entity, its key, and plugin URN.

      Returns [E, K, string][]

      Array of [entity, key, pluginURN] tuples

    • Flat maps over individual entities, applying the transform function to each entity.

      Type Parameters

      • U

        The return type of the mapping function

      Parameters

      • fn: (entity: E, key: K, plugin: string) => U

        Function that transforms an entity, key, and plugin URN into type U

      Returns U[]

      Array of transformed values

    • Retrieves all entities associated with the given key.

      Parameters

      • key: K

        The key to look up

      Returns E[]

      Array of entities for the key, empty array if key not found

    • Returns an iterator over the unique keys in the collection.

      Returns IterableIterator<K>

      Iterator yielding unique keys in insertion order

    • Maps over entity arrays by key, applying the transform function to each group.

      Type Parameters

      • U

        The return type of the mapping function

      Parameters

      • fn: (entities: E[], key: K) => U

        Function that transforms an entity array and key into type U

      Returns U[]

      Array of transformed values

    • Returns an iterator over the entity arrays for each key in the collection.

      Returns IterableIterator<E[]>

      Iterator yielding entity arrays in insertion order