@rvoh/dream
    Preparing search index...

    Function groupBy

    • Groups elements of an array into an object, using a key-generating function.

      Examples: groupBy(['Hello', 'World', 'Hello'], a => a) // { Hello: ['Hello', 'Hello'], World: ['World'] }

      Type Parameters

      • ArrayType extends any[]
      • ElementType extends any

      Parameters

      • arr: ArrayType

        The array to group

      • toKey: (a: ElementType) => string

        Function to generate a key for each element

      Returns Record<string, ArrayType>

      An object mapping keys to arrays of grouped elements