Ramda.js R.anyPass() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Logic

Definition

Ramda’s R.anyPass() answers a logic question: does at least one of these tests pass for the same arguments? You pass an array of predicates. You get back one function. Call that leftover with a value (or several values). You get a boolean. Native JavaScript would write p1(x) || p2(x) || p3(x). anyPass names that OR once, curries the leftover to the longest predicate, and short-circuits on the first true. Drop the leftover into R.filter and R.find.

The official sample is the whole idea. isClub checks suit '♣︎'. isSpade checks suit '♠︎'. Together they accept any black card. A 10 of clubs passes. A queen of spades passes. A queen of diamonds fails. Need every test to pass? That is R.allPass. Need exactly two predicates? That is R.either. Need one predicate on items of a list? That is R.any. Previous Logic helper is R.and. Next is R.both.

Syntax

Call R.anyPass. Start with this line.

Ramda
R.anyPass(predicates)
CallWhat it does
R.anyPass(predicates)Primary signature.
R.anyPass(...)Call the logic helper.

Prefer import { anyPass } from "ramda" when you want a named import.

Library declarations
Ramda
R.anyPass(predicates)

Parameters

ParameterDescription
predicatesRequired. Array. Functions that return a boolean. Each is called with the same arguments you later pass to the leftover. An empty array is allowed.

Return Value

Return ValueDescription
FunctionA curried predicate. true when at least one listed predicate is true for those arguments. false if every test misses. An empty list yields a function that is always false.

Ramda Examples

📚 Getting Started

The official Ramda black-card sample, then the same idea compared with allPass, either, and R.any.

Example 1 — Official Black Card

Both predicates see the same card. Suit must be clubs or spades. One hit is enough to yield true.

Ramda
const isClub = R.propEq('♣︎', 'suit');
const isSpade = R.propEq('♠︎', 'suit');
const isBlackCard = R.anyPass([isClub, isSpade]);

isBlackCard({rank: '10', suit: '♣︎'});
//=> true

isBlackCard({rank: 'Q', suit: '♠︎'});
//=> true

isBlackCard({rank: 'Q', suit: '♦︎'});
//=> false
Try It Yourself

How It Works

Clubs pass isClub, so the leftover is true without needing spades. Spades pass isSpade. Diamonds miss both, so the leftover is false. That is the docs sample from ramdajs.com. In Ramda 0.30, propEq is value then name.

Example 2 — vs allPass, either, and R.any

Same black-card idea. anyPass and either are OR. allPass is AND. R.any walks a list with one predicate.

Ramda
const isClub = R.propEq('♣︎', 'suit');
const isSpade = R.propEq('♠︎', 'suit');
const card = { rank: 'Q', suit: '♠︎' };

R.anyPass([isClub, isSpade])(card);
//=> true

R.allPass([R.propEq('K', 'rank'), isSpade])(card);
//=> false

R.either(isClub, isSpade)(card);
//=> true

R.any(R.equals(3), [1, 3, 5]);
//=> true
Try It Yourself

How It Works

allPass is false because the card is a queen, not a king, even though the suit is a spade. either is the two-predicate form of anyPass. R.any asks a different question: does any item in a list pass one function?

📈 Practical Patterns

An outlier check, a leftover whose arity is 2, then filter and find, then an empty list versus either.

Example 3 — Outliers, Arity, and Two Arguments

Partially applied helpers have arity 1. Unapplied binary helpers keep arity 2, so the leftover waits for two values. OR stops at the first hit.

Ramda
const outlier = R.anyPass([R.gt(R.__, 10), R.lt(R.__, 0)]);

outlier(15);
//=> true

outlier(5);
//=> false

R.anyPass([R.equals, R.identical])(1, 1);
//=> true

R.anyPass([R.equals, R.identical])(1, '1');
//=> true
Try It Yourself

How It Works

R.gt(R.__, 10) has .length 1, so outlier is unary. R.equals and R.identical each have .length 2, so that leftover is curryN(2, …). R.equals(1, '1') is true in Ramda, so OR is true even though identical would fail. With allPass, that pair would be false.

Example 4 — Filter and Find

Build one leftover from two field tests. Keep tickets that are open or on team blue. Find the first match.

Ramda
const pred = R.anyPass([
  R.propEq('open', 'status'),
  R.propEq('blue', 'team')
]);

const rows = [
  { id: 1, status: 'open', team: 'blue' },
  { id: 2, status: 'done', team: 'blue' },
  { id: 3, status: 'open', team: 'red' },
  { id: 4, status: 'done', team: 'red' }
];

R.filter(pred, rows);
//=> [
//     { id: 1, status: 'open', team: 'blue' },
//     { id: 2, status: 'done', team: 'blue' },
//     { id: 3, status: 'open', team: 'red' }
//   ]

R.find(pred, rows);
//=> { id: 1, status: 'open', team: 'blue' }
Try It Yourself

How It Works

Filling the predicate list leaves a function of one object for R.filter and R.find. Row 2 is done but blue. Row 3 is open but red. Row 4 misses both. The same tests with allPass would keep only row 1.

Example 5 — Empty List vs either

An empty predicate list never loops, so the leftover is always false. either is the two-predicate cousin. Three tests still OR.

Ramda
R.anyPass([])(99);
//=> false

R.either(R.gt(R.__, 10), R.lt(R.__, 0))(15);
//=> true

R.anyPass([R.equals(5), R.equals(7), R.equals(9)])(7);
//=> true

R.anyPass([R.equals(5), R.equals(7), R.equals(9)])(3);
//=> false
Try It Yourself

How It Works

Vacuous false: nothing passed, so the leftover is false. Prefer R.either when you will always have exactly two tests. Prefer anyPass when the list can grow. allPass([]) is the opposite: always true.

Browser Support

R.anyPass() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.

✓ Ramda 0.9.0+ · Any JS runtime

Ramda.js R.anyPass()

Load Ramda 0.9.0 or later via CDN or npm, then call R.anyPass with an array of predicates. No extra browser API is required.

100% With Ramda 0.9.0+
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
R.anyPass() Universal

Bottom line: Safe in any project that includes Ramda 0.9.0 or later. 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.anyPass(predicates) takes an array of predicate functions and returns one new predicate. That leftover is true when at least one predicate is true for the same arguments. It is OR for functions. Added in v0.9.0. Type: [(*… → Boolean)] → (*… → Boolean).
isClub = R.propEq('♣︎', 'suit'); isSpade = R.propEq('♠︎', 'suit'); isBlackCard = R.anyPass([isClub, isSpade]). A 10 of clubs is true. A queen of spades is true. A queen of diamonds is false.
anyPass is OR of a list of predicates on the same arguments. allPass is AND of that list. either ORs exactly two predicates. R.any runs one predicate across items in a list until one passes.
It matches the highest .length among the predicates. R.anyPass([R.gt(R.__, 10), R.lt(R.__, 0)]) has arity 1. R.anyPass([R.equals, R.identical]) has arity 2 because both helpers wait for two values.
R.anyPass([]) returns a function that is always false. There is nothing that can pass, so the leftover is vacuously false — the same idea as Array.prototype.some on [].
No. R.anyPass is a stable Ramda logic helper from v0.9.0. It is not deprecated, experimental, or non-standard.

Continue to R.both()

Learn how to AND exactly two predicates with Ramda R.both().

R.both() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful