common-stuff
    Preparing search index...

    Function flatMapRecord

    • Converts object to entries, maps it with provided callback and flattens entry list.

      Type Parameters

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

      Parameters

      • obj: Record<K, V>

        Record like object

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

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

      Returns Record<RK, RV>

      new mapped object

      flatMapRecord({'a': 2}, ([k, v]) => [[k, v]])
      >> {'a': 2, 'b': 3}
      flatMapRecord({'a': 2, 'b': 3}, ([k, v]) => v === 2 ? [[k, v]] : [])
      >> {'a': 2}

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