Groups an array of objects by the specified property.
An object where each key is the stringified value of the specified property, and each value is an array of objects from items that share that property value.
items
const data = [ { index: '0x1600', value: '0x60400010' }, { index: '0x1600', value: '0x60600008' }, { index: '0x1601', value: '0x60fe0120' }];const grouped = groupByProperty(data, 'index');// {// "0x1600": [// { index: "0x1600", value: "0x60400010" },// { index: "0x1600", value: "0x60600008" }// ],// "0x1601": [// { index: "0x1601", value: "0x60fe0120" }// ]// }
The type of objects in the input array.
The key of the property in T to group by.
T
The array of objects to group.
The property name to group by. The property must be a key of T.
Generated using TypeDoc
Groups an array of objects by the specified property.
Returns
An object where each key is the stringified value of the specified property, and each value is an array of objects from
items
that share that property value.Example