Skip to content

GroupByField

cartographer


cartographer / groupByField

groupByField(items, fieldKey): Map<unknown, CatalogItem[]>

Defined in: queries/queryFunctions.ts:422

Group items by a field value.

Each unique field value gets its own group. Items with the same field value appear together.

CatalogItem[]

Array of items to group

string

Field key to group by

Map<unknown, CatalogItem[]>

  • Map of field values to arrays of items with that value
const byStatus = groupByField(items, 'catalog-status');
// { 'raw': [item1, item2], 'approved': [item3, item4] }