( values: T[], )
| 17 | } |
| 18 | |
| 19 | export function countOccurrences<T extends PropertyKey>( |
| 20 | values: T[], |
| 21 | ): Partial<Record<T, number>> { |
| 22 | return values.reduce<Partial<Record<T, number>>>( |
| 23 | (acc, value) => ({ ...acc, [value]: (acc[value] ?? 0) + 1 }), |
| 24 | {}, |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | export function distinct<T extends string | number | boolean>(array: T[]): T[] { |
| 29 | return [...new Set(array)]; |
no outgoing calls
no test coverage detected