Ramda.js R.useWith() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

R.useWith(fn, transformers) returns a new curried function. When it is called, each argument goes through its own transformer first, and then fn receives the transformed values (official Ramda docs). Think of it as “clean every input, then run the real work.”

Stable since v0.1.0: R.useWith is not deprecated, experimental, or non-standard. Tip from the docs: pass R.identity for arguments that need no change, so the new function reports the correct arity.

Syntax

Call R.useWith. Start with this line.

Ramda
R.useWith(fn, [t1, t2, …])(a, b, …)
CallWhat it does
R.useWith(fn, [t1, t2, …])(a, b, …)Primary signature.
R.useWith(...)Call the function helper.

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

Library declarations
Ramda
R.useWith(fn, [t1, t2, …])(a, b, …)

Parameters

ParameterDescription
fnRequired. The main function that receives the transformed arguments
transformersRequired. Array of one-argument functions, matched to arguments by position (up to 10)

Return Value

Return ValueDescription
*A curried function with arity transformers.length

Ramda Examples

Example 1 — Official Math.pow Samples

Leave both arguments as they are, then adjust them with R.dec and R.inc.

Ramda
console.log(R.useWith(Math.pow, [R.identity, R.identity])(3, 4)); // 81
console.log(R.useWith(Math.pow, [R.dec, R.inc])(3, 4));           // 32
console.log(R.useWith(Math.pow, [R.dec, R.inc])(3)(4));           // 32
Try It Yourself

How It Works

  1. No change. R.identity returns its input, so the call is Math.pow(3, 4) = 81.
  2. Adjust each slot. R.dec(3) → 2 and R.inc(4) → 5.
  3. Call the main function. Math.pow(2, 5) = 32.
  4. Curried. (3)(4) gives the same 32, because the result waits for two arguments.

Example 2 — Case-Insensitive Comparison

Lowercase both strings before R.equals compares them.

Ramda
const sameText = R.useWith(R.equals, [R.toLower, R.toLower]);

console.log(R.equals('Ada', 'ADA')); // false
console.log(sameText('Ada', 'ADA')); // true
console.log(sameText('Ada', 'Bob')); // false
Try It Yourself

How It Works

  1. Plain compare. R.equals('Ada', 'ADA') is false because the case differs.
  2. Transform first. R.toLower turns both inputs into 'ada'.
  3. Then compare. R.equals('ada', 'ada') → true.
  4. Different names. 'ada' vs 'bob' → false.

Example 3 — Build a findById Helper

Turn an id into a matcher, keep the list as it is, then let R.find do the search.

Ramda
const users = [{ id: 1, name: 'Ada' }, { id: 2, name: 'Linus' }];

const byId = id => user => user.id === id;
const findById = R.useWith(R.find, [byId, R.identity]);

console.log(findById(2, users)); // { id: 2, name: 'Linus' }
console.log(findById(9, users)); // undefined
Try It Yourself

How It Works

  1. Slot 0 — the id. byId(2) becomes the test user => user.id === 2.
  2. Slot 1 — the list. R.identity passes users through unchanged.
  3. Search. R.find(test, users) returns the first match, Linus.
  4. No match. With id 9, nothing passes the test, so the result is undefined.

Example 4 — Arity Comes from the Transformer List

Extra arguments reach fn unchanged, but only the listed transformers count toward arity.

Ramda
const list3 = (a, b, c) => [a, b, c];

const short = R.useWith(list3, [R.inc]);
const full = R.useWith(list3, [R.inc, R.identity, R.identity]);

console.log(short(1, 2, 3));  // [2, 2, 3]
console.log(short.length);    // 1
console.log(full.length);     // 3
console.log(typeof full(1));  // "function"
Try It Yourself

How It Works

  1. Extras pass through. short has one transformer, so 1 becomes 2 while 2 and 3 arrive unchanged.
  2. Arity 1. short.length is 1, so short(1) runs right away and returns [2, undefined, undefined].
  3. Pad with identity. full lists three transformers, so its arity is 3.
  4. Currying waits. full(1) returns a function until b and c arrive — the reason the docs recommend R.identity.

Example 5 — useWith vs converge

Same main function and transformers, but the arguments are routed differently.

Ramda
console.log(R.useWith(R.add, [R.inc, R.dec])(10, 20)); // 30
console.log(R.converge(R.add, [R.inc, R.dec])(10));     // 20
Try It Yourself

How It Works

  1. useWith: one each. R.inc(10) → 11 and R.dec(20) → 19.
  2. Add. R.add(11, 19) → 30.
  3. converge: same input everywhere. R.converge sends 10 to both branches: 11 and 9.
  4. Add. R.add(11, 9) → 20. Different arguments? useWith. One shared input? converge.

Browser & Runtime Support

R.useWith() is plain JavaScript inside Ramda (available since v0.1.0). It uses no browser API, so support depends only on loading Ramda.

✓ Ramda 0.1.0+ · Any JS runtime

Ramda.js R.useWith()

The UMD build (ramda.min.js) is compiled to ES5 syntax, so it runs in Chrome, Firefox, Safari, and Edge. Via npm it works in Node.js, Deno, and Bun with require or import. The arrow functions in some examples need an ES2015+ engine, which every modern browser has.

100% With Ramda loaded
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.useWith() Universal

Bottom line: Safe in any project that includes Ramda. Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. These labs load [email protected] from jsDelivr.

Frequently Asked Questions

R.useWith(fn, [t1, t2, ...]) returns a new curried function. When you call it, each argument is first passed through its own transformer (t1 gets the first argument, t2 the second, and so on), and then fn is called with the transformed values.
R.useWith(Math.pow, [R.dec, R.inc])(3, 4) returns 32, because it calls Math.pow(R.dec(3), R.inc(4)), which is Math.pow(2, 5). With [R.identity, R.identity] the same call returns 81.
R.useWith gives each argument its own transformer: t1(a), t2(b). R.converge sends the same arguments through every branch: f(a, b), g(a, b). Use useWith when each position needs a different change.
Arguments beyond the number of transformers are passed to fn unchanged. The docs recommend adding R.identity for them anyway, so the new function reports the correct arity and currying waits for every argument.
It equals the number of transformers. R.useWith(fn, [R.inc]).length is 1, while R.useWith(fn, [R.inc, R.identity, R.identity]).length is 3. The length of fn itself is ignored.
No. R.useWith has been a stable Ramda function helper since v0.1.0. It is not deprecated, experimental, or non-standard.

Next: R.adjust()

Start the List section by updating a single item at a given index.

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