Something went wrong. Try again.
source dump of claude code forked from oppi.li/claude-code
Something went wrong. Try again.
511 B · 18 lines
TypeScript
at main
12345678910111213141516171819/** * https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.groupby */export function objectGroupBy<T, K extends PropertyKey>( items: Iterable<T>, keySelector: (item: T, index: number) => K,): Partial<Record<K, T[]>> { const result = Object.create(null) as Partial<Record<K, T[]>> let index = 0 for (const item of items) { const key = keySelector(item, index++) if (result[key] === undefined) { result[key] = [] } result[key].push(item) } return result}