Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object/keyBy

Index

References

Functions

References

Renames and re-exports keyBy

Functions

  • keyBy<O, KT>(fn: ObjBaseBy<O, KT>, obj: O): Record<KT, O[keyof O]>
  • keyBy<K, V, KT>(fn: ObjBase<K, V, KT>): <O>(obj: O) => Record<KT, O[keyof O]>
  • Creates an object composed of keys generated from the results of running each element of object thru fn. The corresponding value of each key is the last element responsible for generating the key

    example
     keyBy(x => x < 2, { a: 0, b: 1, c: 3});//=> { false: 1, true: 3 }
    

    Type parameters

    • O

    • KT: string

    Parameters

    • fn: ObjBaseBy<O, KT>

      The function to transform value to group key. Receives three argument, value, key, obj.

    • obj: O

      The obj to iterate over.

    Returns Record<KT, O[keyof O]>

    Returns the composed aggregate object.

  • Creates an object composed of keys generated from the results of running each element of object thru fn. The corresponding value of each key is the last element responsible for generating the key

    example
     keyBy(x => x < 2, { a: 0, b: 1, c: 3});//=> { false: 1, true: 3 }
    

    Type parameters

    • K: string | number | symbol

    • V

    • KT: string

    Parameters

    • fn: ObjBase<K, V, KT>

      The function to transform value to group key. Receives three argument, value, key, obj.

    Returns <O>(obj: O) => Record<KT, O[keyof O]>

    Returns the composed aggregate object.

      • <O>(obj: O): Record<KT, O[keyof O]>
      • Type parameters

        • O: Record<K, V>

        Parameters

        • obj: O

        Returns Record<KT, O[keyof O]>

Generated using TypeDoc