@adviser/cement - v0.0.0
    Preparing search index...

    Interface KeyedNgOptions<K, V, CTX>

    Configuration options for creating a KeyedNg instance.

    const options: KeyedNgOptions<string, MyValue, MyContext> = {
    createValue: (item) => new MyValue(item.givenKey),
    key2string: (key) => key.toLowerCase(),
    ctx: { config: 'default' },
    lru: { max: 100 }
    };
    interface KeyedNgOptions<K, V, CTX> {
        createValue: (keyItem: KeyedNgItem<K, V, CTX>) => V;
        key2string?: (key: K) => string;
        ctx?: CTX;
        resetAfter?: number;
        lru?: Partial<Readonly<MutableLRUParam<unknown, string>>>;
    }

    Type Parameters

    • K

      The key type

    • V

      The value type

    • CTX

      The context type

    Index

    Properties

    createValue: (keyItem: KeyedNgItem<K, V, CTX>) => V

    Factory function that creates a value for a given key.

    Called once per unique key when the value is first accessed. The function receives a KeyedNgItem with value initially undefined.

    Type Declaration

      • (keyItem: KeyedNgItem<K, V, CTX>): V
      • Parameters

        • keyItem: KeyedNgItem<K, V, CTX>

          The item containing key, context, and placeholder for value

        Returns V

        The created value instance

    key2string?: (key: K) => string

    Optional function to convert keys to strings for internal storage.

    If not provided, uses default conversion:

    • strings: as-is
    • numbers: toString()
    • booleans: "true" or "false"
    • objects: JSON.stringify with sorted keys

    Type Declaration

      • (key: K): string
      • Parameters

        • key: K

          The key to convert

        Returns string

        A string representation of the key

    ctx?: CTX

    Optional default context passed to value creation.

    Can be overridden on a per-get basis. Defaults to empty object.

    resetAfter?: number
    lru?: Partial<Readonly<MutableLRUParam<unknown, string>>>

    Optional LRU cache configuration.

    When provided, the collection will automatically evict least-recently-used items when size limits are exceeded.