Module src/arrays/groupBy
Functions
Const groupBy
- groupBy<T>(array: Array<T>, getGroupKey: string | ((o: object) => string)): Record<string, T[]>
-
Type parameters
Parameters
-
array: Array<T>
-
getGroupKey: string | ((o: object) => string)
Returns Record<string, T[]>
groupBy - Creates an object composed of keys generated from the results of running each element of array thru getKey
groupBy(['one', 'two', 'three'], 'length'); // return { '3': ['one', 'two'], '5': ['three'] }