platform-bible-utils
    Preparing search index...

    Function groupBy

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

      There are two overloads:

      • groupBy(items, keySelector) – groups the original items using the key returned by keySelector.
      • groupBy(items, keySelector, valueSelector) – groups transformed values using the key returned by keySelector and the value returned by valueSelector.

      If valueSelector is not provided, the original item is used in the resulting groups.

      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

      There are two overloads:

      • groupBy(items, keySelector) – groups the original items using the key returned by keySelector.
      • groupBy(items, keySelector, valueSelector) – groups transformed values using the key returned by keySelector and the value returned by valueSelector.

      If valueSelector is not provided, the original item is used in the resulting groups.

      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

      Returns Map<K, V[]>

      Map of keys to groups of values corresponding to each item.