whereAny
See original GitHub issueIs your feature request related to a problem? Please describe.
Takes a spec object and a test object; returns true if the test satisfies the spec. Each of the spec’s own properties must be a predicate function. Each predicate is applied to the value of the corresponding property of the test object. where returns true if one of the predicates return true, false otherwise. This function is just like R.where but uses boolean OR
instead or boolean AND
Describe the solution you’d like
Possible implementation
const whereAny = R.curry((spec, testObj) => {
for (let [key, fn] of Object.entries(spec)) {
if (fn(testObj[key])) {return true}
}
return false
})
const pred = searchValue => whereAny({
a: R.includes(searchValue),
b: R.equals(searchValue),
x: R.gt(R.__, 3),
y: R.lt(R.__, 3)
});
Describe alternatives you’ve considered
–
Additional context
Originally conceived on SO: https://stackoverflow.com/questions/55688667/ramda-whereany
R.where
- https://ramdajs.com/docs/#where
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
SQL WHERE ANY | WHERE ALL - Dofactory
ANY and ALL operators are used with WHERE or HAVING. ANY and ALL operate on subqueries that return multiple values. ANY returns true...
Read more >whereAny - The Grails Framework 3.1.1
Defines a new grails.gorm.DetachedCriteria instance that uses a disjunction (logical OR). Examples. Basic query: def query = Person.whereAny { firstName == ...
Read more >C# (CSharp) SqlBuilder.WhereAny Examples
WhereAny - 1 examples found. These are the top rated real world C# (CSharp) examples of SqlBuilder.WhereAny extracted from open source projects.
Read more >Ramda: whereAny? - javascript - Stack Overflow
I'm trying to build myself whereAny . Ramda exposes where which checks if every prop it is given satisfies the respective predicate.
Read more >net.bytebuddy.matcher.ElementMatchers.whereAny java code ...
public static ElementMatcher.Junction > whereNone(ElementMatcher matcher) { return not(whereAny(matcher));
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kcouliba you didn’t give me chance to respond to your comment here. It seems that somebody already implemented this function in ramda.
Having said that, we’ll not be incorporated this function into Ramda Adjunct as well. I’m sorry you’d have to go through the trouble of implementing it.
@char0n no problem, I had fun implementing it. I’ll be looking forward to other functions to implement