Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/arrays/groupBy

Index

Functions

Functions

Const groupBy

  • groupBy<T>(array: Array<T>, getGroupKey: string | ((o: object) => string)): Record<string, T[]>
  • groupBy - Creates an object composed of keys generated from the results of running each element of array thru getKey

    example

    groupBy(['one', 'two', 'three'], 'length'); // return { '3': ['one', 'two'], '5': ['three'] }

    Type parameters

    • T

    Parameters

    • array: Array<T>
    • getGroupKey: string | ((o: object) => string)

    Returns Record<string, T[]>

Generated using TypeDoc