(array: T[], getKey: (item: T) => string | number)
| 11 | } |
| 12 | |
| 13 | export function group<T>(array: T[], getKey: (item: T) => string | number) { |
| 14 | const o: Record<string, T[]> = {} |
| 15 | |
| 16 | array.forEach((item) => { |
| 17 | const key = getKey(item) |
| 18 | o[key] = [...(o[key] ?? []), item] |
| 19 | }) |
| 20 | |
| 21 | return o |
| 22 | } |
| 23 | |
| 24 | export function copy(text: string) { |
| 25 | return navigator.clipboard.writeText(text) |
no test coverage detected