Pavlo
Pavlo

Reputation: 44957

How to check if some of the object values match the predicate in Ramda?

Since there is no R.some, how do I implement the following in Ramda?

const hasKey = (predicate, object) =>
  Object.keys(object)
    .map(key => object[key])
    .some(predicate);

Upvotes: 2

Views: 1300

Answers (1)

Bergi
Bergi

Reputation: 665070

Since there is no R.some

It's known as any.

how do I implement the following in Ramda?

You would write

const hasKey = (p, o) => R.any(p, R.values(o))

Upvotes: 5

Related Questions