Groups an array of objects by the return value of a callback function.
The array of objects to group
The callback function returning the group key
A record containing arrays of grouped objects
const groups = byKey([{ id: 1, type: 'A' }, { id: 2, type: 'A' }], itm => itm.type); Copy
const groups = byKey([{ id: 1, type: 'A' }, { id: 2, type: 'A' }], itm => itm.type);
Groups an array of objects by a sequence of key fields.
The sequence of object keys to group by
const groups = byKey(users, 'department', 'role'); Copy
const groups = byKey(users, 'department', 'role');
Groups an array of objects by the return value of a callback function.