• Groups items by grouping function.

    Type Parameters

    • T
    • K

    Parameters

    • array: T[]

      The items to group.

    • getKey: ((item: T, index: number) => K)

      A function that returns a key indicating which group the item belongs to.

        • (item, index): K
        • Parameters

          • item: T
          • index: number

          Returns K

    Returns Map<K, T[]>

    An object containing groups, keyed by group key. The order of items is preserved within each group.