Documentation
    Preparing search index...
    • groups an array of elements into multiple arrays on an object where the key is the string returned by the groupKey function.

      If the groupKey function returns undefined, the value won't be included in the result. This can be used to filter out values from the initial array.

      There's also an ECMAScript proposal that will add a very similar function on Object and Array: https://github.com/tc39/proposal-array-grouping

      This function can be deprecated once it's widely released.

      Type Parameters

      • T
      • K extends string

      Parameters

      • elements: T[]
      • groupKey: (element: T) => K | undefined

      Returns Record<K, T[]>