Skip to content

_.overEvery and _.overSome may accept _.matchesProperty shortcut (and probably others) #2193

@jrencz

Description

@jrencz

Consider the following:

_(collection)
  .filter(['some_id', someObj.id])
  .filter(['some_token', anotherObj.token])
  .filter(somePredicateFunction)
  .value();

might as well be written as:

_(collection)
  .filter(_.overEvery(
    _.partial(_.matchesProperty, _, ['some_id', someObj.id]),
    _.partial(_.matchesProperty, _, ['some_token', anotherObj.token]),
    somePredicateFunction
  )
  .value();

or for readability as:

_(collection)
  .filter(_.overEvery(
    ['some_id', someObj.id],
    ['some_token', anotherObj.token],
    somePredicateFunction
  )
  .value();

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