Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

unique-by.ts

3 lines156 Bytes

1export function uniqueBy<T>(arr: Array<T>, fn: (x: T) => unknown): Array<T> {
2 return arr.filter((x, i, a) => a.findIndex((y) => fn(x) === fn(y)) === i)
3}