Ramda’s R.whereAny() answers a spec question: does this object pass at least one named predicate? You pass a spec object whose own values are functions, then the test object. You get a boolean. Extra keys on the test object do not matter. A missing spec key is still tested, with undefined. Native JavaScript would write several if checks joined with ||. whereAny names those checks once, stays data-last, and curries, so R.whereAny(spec) is already a function of one object — ready for R.filter and R.find.
The official sample is the whole idea. Four predicates sit on the spec: a equals 'foo', b is not 'xxx', x is greater than 10, y is less than 20. One true leftover is enough. The first docs row has a failed x and y, but a still matches, so the leftover is true. Need every predicate to pass? That is R.where. Need literals instead of functions? That is R.whereEq. Need one key only? That is R.propSatisfies. Previous Object helper is R.where. Next is R.whereEq.
Syntax
Call R.whereAny. Start with this line.
Ramda
R.whereAny(spec, testObj)
Call
What it does
R.whereAny(spec, testObj)
Primary signature.
R.whereAny(...)
Call the object helper.
Prefer import { whereAny } from "ramda" when you want a named import.
Library declarations
Ramda
R.whereAny(spec, testObj)
Parameters
Parameter
Description
spec
Required. Object. Own properties must be predicate functions. Each is called with testObj[key]. Inherited spec keys are skipped.
testObj
Required. Object. The record under test. Extra keys are ignored. A missing spec key reads as undefined.
Return Value
Return Value
Description
Boolean
true when any own spec predicate returns a truthy leftover. Otherwise false. Neither object is mutated. An empty spec yields false.
Ramda Examples
📚 Getting Started
The official Ramda object sample, then the same idea compared with where and whereEq.
Example 1 — Official pred
One true leftover is enough. Extra keys would be ignored. Every field can fail except one.
b: R.complement(R.equals('xxx')) means b must not be 'xxx'. The first row still passes because a is 'foo', even though x and y fail. Rows 2 and 3 miss every test. That is the docs sample from ramdajs.com.
Example 2 — vs where, whereEq, and propSatisfies
Same row. whereAny is OR. where is AND. whereEq uses literals. propSatisfies tests one key.
extra is ignored. whereAny is true because a matches even though b does not. where and whereEq need both keys. Prefer where when every leftover must pass.
📈 Practical Patterns
Extra keys, missing fields, an empty spec that yields false, then filter and find, then why literals still throw.
Example 3 — Extra Keys, Missing Keys, Empty Spec
Extra fields do not fail the spec. A missing field still runs the predicate with undefined. An empty spec never loops, so the leftover is false — the opposite of R.where.
Age 21 passes the age test. A vip flag passes without an age. A missing age and vip both yield undefined, so both predicates fail. R.whereAny({}, null) is also false, because the loop never finds a true leftover. A non-empty spec on null throws.
Example 4 — Curry, Filter, and Find
Fill the spec to get a predicate of one row. Keep tickets that are open or high-scoring. Find the first match.
Because whereAny is arity 2, filling spec leaves a function of one object for R.filter and R.find. Row 1 matches status. Row 2 matches score. Row 3 matches neither. That is the docs use case: declarative OR constraints for list helpers.
Example 5 — Literals Still Throw
A number in the spec is not a predicate. Wrap it with R.equals. There is no whereAnyEq.
Spec values must still be functions. R.whereAny({ a: 1 }, { a: 1 }) throws because 1 is not callable. The second line shows AND: where needs both keys. Wrap literals with R.equals. There is no whereAnyEq helper.
Compatibility
Browser Support
R.whereAny() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.28.0+ · Any JS runtime
Ramda.js R.whereAny()
Load Ramda 0.28.0 or later via CDN or npm, then call R.whereAny with a spec of predicates and a test object. No extra browser API is required.
100%With Ramda 0.28.0+
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
R.whereAny()Universal
Bottom line: Safe in any project that includes Ramda 0.28.0 or later. Spec values must be functions. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node. These labs use [email protected].
Frequently Asked Questions
R.whereAny(spec, testObj) returns true when at least one own spec property is a predicate that returns true for testObj of that same key. Extra keys on the test object are ignored. Added in v0.28.0.
const pred = R.whereAny({ a: R.equals('foo'), b: R.complement(R.equals('xxx')), x: R.gt(R.__, 10), y: R.lt(R.__, 20) }). pred({a:'foo', b:'xxx', x:8, y:34}) is true because a matches. The two all-miss rows are false. The last two official rows are true.
whereAny is OR: one passing predicate is enough. where is AND: every predicate must pass. whereEq compares spec values with R.equals instead of calling functions.
The predicate still runs, with undefined. That leftover is rarely true, so a missing key usually does not count as a pass. An empty spec {} returns false, even for null, because no predicate ever succeeds.
No. Spec values must be functions. R.whereAny({ a: 1 }, { a: 1 }) throws because 1 is not callable. Wrap with R.equals, or use R.whereEq when every leftover is a value and you need AND.
No. R.whereAny is a stable Ramda object helper from v0.28.0. It is not deprecated, experimental, or non-standard.