Function
uniqueBy
(array: readonly T[], equalFn: (a: any, b: any) => boolean)
Source from the content-addressed store, hash-verified
| 75 | * @category Array |
| 76 | */ |
| 77 | export function uniqueBy<T>(array: readonly T[], equalFn: (a: any, b: any) => boolean): T[] { |
| 78 | return array.reduce((acc: T[], cur: any) => { |
| 79 | const index = acc.findIndex((item: any) => equalFn(cur, item)) |
| 80 | if (index === -1) |
| 81 | acc.push(cur) |
| 82 | return acc |
| 83 | }, []) |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Get last item |
Callers
nothing calls this directly
Tested by
no test coverage detected