common-stuff
    Preparing search index...

    Function mapRecord

    • Converts object to entries and maps it with provided callback.

      Type Parameters

      • K extends PropertyKey
      • V
      • RK extends PropertyKey
      • RV

      Parameters

      • obj: Record<K, V>

        Record like plain object

      • callback: (entry: [K, V]) => [RK, RV]

        map callback, accepts entry pair ([key, value]) and should return entry pair

      Returns Record<RK, RV>

      new mapped object

      mapRecord({'a': 2}, ([k, v]) => [v, k * 2])
      >> {'b': 4}
      mapRecord({'a': 'b'}, ([k, v]) => [v, k])
      >> {'b': 'a'}

      Use [[map]] from iterable instead — it handles Record directly along with Array, Set, Map, and (async) iterables.