// Not `Map.groupBy`: the relay runs this core on Node 18, which lacks it. export function groupedBy(items: readonly T[], keyOf: (item: T) => K): Map { const groups = new Map() for (const item of items) { const key = keyOf(item) const group = groups.get(key) if (group) { group.push(item) } else { groups.set(key, [item]) } } return groups }