Performs right-to-left function composition using a transforming function (official Ramda docs). The last function may have any arity; the rest must be unary. Unlike compose, the functions are passed in an array.
Stable since v0.26.0:R.composeWith is a core Ramda helper — not deprecated, experimental, or non-standard. Unlike R.compose, functions are passed in an array, and the transformer is not used on the rightmost step.
Syntax
Call R.composeWith. Start with this line.
Ramda
R.composeWith(transformer, functions)
Call
What it does
R.composeWith(transformer, functions)
Primary signature.
R.composeWith(...)
Call the function helper.
Prefer import { composeWith } from "ramda" when you want a named import.
Library declarations
Ramda
R.composeWith(transformer, functions)
Parameters
Parameter
Description
transformer
Required. (f, res) → * — gate between steps
functions
Required. Array; rightmost may be multi-arg; others unary
Return Value
Return Value
Description
*
One function (not auto-curried)
Ramda Examples
Example 1 — Official composeWhileNotNil
Increment age when it exists; skip when the property is missing.
Empty stops. Transformer returns '' and skips toUpper.
Same pattern as nil. Change the sentinel; keep the gate shape.
Compatibility
Browser & Runtime Support
R.composeWith() is ordinary JavaScript once Ramda is loaded. It needs no special browser API — only a JS runtime that can run Ramda v0.26.0+.
✓ Ramda 0.26.0+ · Any JS runtime
Ramda.js R.composeWith()
Works in every modern browser and runtime where you can load Ramda 0.26.0 or later (CDN or npm). Older Ramda builds before 0.26.0 do not include composeWith.
100%With Ramda 0.26+
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
R.composeWith()Universal
Bottom line: Safe in any project that includes Ramda 0.26.0 or later. Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Bun, and Deno.
Frequently Asked Questions
R.composeWith(transformer, functions) composes an array of functions right to left, but each step except the last is wrapped by the transformer. The transformer receives (f, res) and decides whether to call f(res), skip, or replace the value.
const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res)); then composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) yields 2, and the same pipeline on {} yields undefined. Added in v0.26.0. See also R.compose and R.pipeWith.
compose takes functions as separate arguments. composeWith takes a transformer first, then an array of functions. compose always calls every function. composeWith lets the transformer skip or change a step. The last (rightmost) function still runs without the transformer.
No. The docs note that the transforming function is not used on the last argument. The rightmost function in the array runs first, with the original input. Later steps (moving left) go through the transformer.
No. The result of composeWith is not automatically curried. Call it with every argument the rightmost function needs, in one go. composeWith itself is curried, so you can name a transformer once and reuse it on different arrays.
No. R.composeWith is a stable Ramda function helper from v0.26.0. It is not deprecated, experimental, or non-standard.