Ramda.js R.on() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

Takes a binary function f, a unary function g, and two values — applies g to each value, then combines the results with f: f(g(a), g(b)). Also known as the P combinator. Part of Ramda Function since v0.28.0 (stable — not deprecated).

Note: Same mapper on two values, then one binary. For two mappers on one value, use R.converge.

Syntax

Call R.on. Start with this line.

Ramda
R.on(f, g, a, b) or R.on(f, g)(a, b)
CallWhat it does
R.on(f, g, a, b) or R.on(f, g)(a, b)Primary signature.
R.on(...)Call the function helper.

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

Library declarations
Ramda
R.on(f, g, a, b) or R.on(f, g)(a, b)

Parameters

ParameterDescription
fRequired. Binary function that combines the two mapped values
gRequired. Unary function applied to each of a and b
a, bRequired. The two values to transform, then combine

Return Value

Return ValueDescription
*Whatever f(g(a), g(b)) returns

Ramda Examples

Example 1 — Official eqBy

Prefill a binary equals, then compare two objects on property a.

Ramda
const eqBy = R.on((a, b) => a === b);

eqBy(R.prop("a"), { b: 0, a: 1 }, { a: 1 });
// → true
Try It Yourself

How It Works

  1. Prefill f. R.on((a, b) => a === b) waits for g, then two values.
  2. Map both. R.prop("a") reads 1 from each object.
  3. Compare. 1 === 1 → true.
  4. Extra keys ignored. b: 0 never enters the comparison.

Example 2 — Official containsInsensitive

Lowercase both sides, then test includes.

Ramda
const containsInsensitive = R.on(R.includes, R.toLower);

containsInsensitive("o", "FOO");
// → true
Try It Yourself

How It Works

  1. Shared g. R.toLower runs on both arguments.
  2. Mapped. "o" and "foo".
  3. Binary f. R.includes("o", "foo") → true.
  4. Pattern. Case-insensitive contains without repeating toLower.

Example 3 — Concat After toUpper

Uppercase two strings, then concatenate them.

Ramda
R.on(R.concat, R.toUpper, "ab", "cd");
// → "ABCD"
Try It Yourself

How It Works

  1. Map. toUpper("ab") → "AB"; toUpper("cd") → "CD".
  2. Combine. R.concat("AB", "CD") → "ABCD".
  3. Order. First value becomes the left side of f.
  4. Reuse. Works for any unary + binary pair with matching types.

Example 4 — R.on vs R.converge

One value / two mappers vs two values / one mapper.

Ramda
R.converge(R.concat, [R.toUpper, R.toLower])("Yodel");
// → "YODELyodel"   // one value, two transforms

R.on(R.concat, R.toUpper, "ab", "cd");
// → "ABCD"         // two values, one transform
Try It Yourself

How It Works

  1. converge. Feeds the same "Yodel" to upper and lower, then concat.
  2. on. Feeds "ab" and "cd" through the same upper, then concat.
  3. Choose converge when branches differ on one input.
  4. Choose on when both inputs share one prep step.

Example 5 — R.on vs R.eqBy

General equals-after-map with on, specialized helper with eqBy.

Ramda
R.on(R.equals, R.toLower, "Foo", "FOO");
// → true

R.eqBy(R.prop("a"), { a: 1 }, { a: 1 });
// → true

R.on(R.equals, R.prop("a"), { a: 1 }, { a: 2 });
// → false
Try It Yourself

How It Works

  1. Case fold. on(equals, toLower) compares lowered strings.
  2. eqBy shortcut. R.eqBy(g, a, b) is equals after g.
  3. Failing case. Props 1 and 2 → false.
  4. Rule. Prefer eqBy for equality; use on for any binary f.

Browser & Runtime Support

R.on is a Ramda Function helper since v0.28.0. It runs anywhere Ramda 0.28+ runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install ramda.

✓ Stable · Ramda 0.28.0+

R.on()

Available in full Ramda builds from v0.28.0 onward. Works in evergreen browsers and current Node LTS when Ramda is loaded.

100% With Ramda 0.28+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
R.on Ramda 0.28.0+

Bottom line: Safe for production on Ramda 0.28+. Ideal for case-insensitive compares, property compares, and any f(g(a), g(b)) pattern. Official reference: ramdajs.com/docs/#on.

Frequently Asked Questions

R.on(f, g, a, b) returns f(g(a), g(b)). g runs on each value, then the binary function f combines those two results. Also known as the P combinator. Added in v0.28.0.
eqBy = R.on((a, b) => a === b); eqBy(R.prop('a'), {b:0, a:1}, {a:1}) //=> true. containsInsensitive = R.on(R.includes, R.toLower); containsInsensitive('o', 'FOO') //=> true.
on applies the same unary g to two different values, then f. converge applies several (possibly different) functions to the same arguments, then f. on(f, g, a, b) is f(g(a), g(b)). converge(f, [g, h])(x) is f(g(x), h(x)).
R.eqBy(g, a, b) is R.on(R.equals, g, a, b). eqBy is the specialized compare-after-mapping helper. on is the general combinator: any binary f, not only equals.
Yes. It is curryN(4), so R.on(f, g, a, b), R.on(f, g)(a, b), and R.on(f)(g)(a)(b) all work. The official eqBy sample pre-fills only f.
No. R.on is a stable Ramda Function helper from v0.28.0. It is not deprecated, experimental, or non-standard.

Next: R.once()

Wrap a function so it runs only on the first call and caches that result.

R.once() 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.

11 people found this page helpful