• Groups each item in the array of items into a map according to the keySelector

    Type Parameters

    • T
    • K

    Parameters

    • items: T[]

      Array of items to group by

    • keySelector: (item: T) => K

      Function to run on each item to get the key for the group to which it belongs

    Returns Map<K, T[]>

    Map of keys to groups of values corresponding to each item

  • Groups each item in the array of items into a map according to the keySelector

    Type Parameters

    • T
    • K
    • V

    Parameters

    • items: T[]

      Array of items to group by

    • keySelector: (item: T) => K

      Function to run on each item to get the key for the group to which it belongs

    • valueSelector: (item: T, key: K) => V

      Function to run on each item to get the value it should have in the group (like map function). If not provided, uses the item itself

    Returns Map<K, V[]>

    Map of keys to groups of values corresponding to each item