Skip to content
0

katanakit-js / useGroupBy

Function: useGroupBy() ​

ts
function useGroupBy<T>(array, key): Record<string, T[]>;

Defined in: src/core/services/utils.service.ts:446

Groups array items by a key property or key selector function.

Type Parameters ​

Type Parameter
T

Parameters ​

ParameterType
arrayT[]
keykeyof T | ((item) => string)

Returns ​

Record<string, T[]>

Example ​

ts
useGroupBy(items, "type");

Released under the MIT License.