es-toolkit
es-toolkit copied to clipboard
Inconsistent api between sortBy and uniqBy
I noticed this difference between the sortBy and uniqBy (and maybe other functions) where the sortBy takes an array and either a list op properties or a list of mapper functions But uniqBy only takes a mapper function
Is there a reason for this?
Or could we extend the uniqBy api to:
uniqBy(T[], keyof T | (item: T) => U)
- items: same as before
- second argument:
- either a property name string
- or a mapper function that returns the value to check for uniqueness
In my code this would quite often make it easier to read since i wouldn't always need a mapper arrow function.