ts-data-forge
    Preparing search index...
    • Creates a new IMapMapped instance with custom key transformation functions.

      This factory function creates an immutable map that can use complex objects as keys by providing bidirectional transformation functions. The toKey function converts your custom key type to a primitive type that can be efficiently stored, while fromKey reconstructs the original key type for iteration and access.

      Performance: O(n) where n is the number of entries in the iterable.

      Type Parameters

      • K

        The type of the custom keys.

      • V

        The type of the values.

      • KM extends Primitive

        The type of the mapped primitive keys.

      Parameters

      • iterable: Iterable<readonly [K, V]>

        An iterable of key-value pairs using the custom key type.

      • toKey: (a: K) => KM

        A function that converts a custom key K to a primitive key KM. This function must be deterministic and produce unique values for unique keys.

      • fromKey: (k: KM) => K

        A function that converts a primitive key KM back to the custom key K. This should be the inverse of toKey.

      Returns IMapMapped<K, V, KM>

      A new IMapMapped instance containing all entries from the iterable.