UNPKG

assistan-ts

Version:

A typesafe and code-first library to define and run OpenAI assistants

12 lines (11 loc) 269 B
export const groupBy = <T, K extends keyof T>( arr: T[], keySelector: (it: T) => string ): Record<string, T> => { const res: Record<string, T> = {}; arr.forEach((it) => { const key = keySelector(it); if (!res[key]) res[key] = it; }); return res; };