Groups an array of objects by a callback function, retaining only the last entry per group.
The array of objects to group
The callback function returning the group key
A record containing the last object from each group
const latest = byLkp(events, ev => ev.id); Copy
const latest = byLkp(events, ev => ev.id);
Groups an array of objects by key fields, retaining only the last entry per group.
The sequence of object keys to group by
const latest = byLkp(events, 'type'); Copy
const latest = byLkp(events, 'type');
Groups an array of objects by a callback function, retaining only the last entry per group.