Skip to content

Inconsistent api between sortBy and uniqBy #1512

@bertyhell

Description

@bertyhell

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.

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions