Generic uniqueBy
Medium · Generics
Write uniqueBy<T, K extends keyof T>(items: T[], key: K): T[] that removes items whose key value was already seen.
Keep the first occurrence of each value and preserve the original order. A Set<T[K]> is a good way to remember seen values.
Next: Generic sortBy