Ramda.js R.reduced() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.reduced(x) wraps a value to say “stop here, this is the final answer.” Return it from the reducer of R.reduce (or a related fold), and Ramda skips the rest of the list and returns the unwrapped x (official Ramda docs). It is Ramda’s version of break for folds.

Stable since v0.15.0: R.reduced is not deprecated, experimental, or non-standard. Note: the wrapper is a black box — its internal shape is not guaranteed, so never read its properties yourself.

Syntax

Call R.reduced. Start with this line.

Ramda
R.reduced(x), returned from a reducer Type a → *
CallWhat it does
R.reduced(x), returned from a reducer Type a → *Primary signature.
R.reduced(...)Call the list helper.

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

Library declarations
Ramda
R.reduced(x), returned from a reducer Type a → *

Parameters

ParameterDescription
xRequired. The final value; any type, including 0, '', or null

Return Value

Return ValueDescription
*An opaque wrapper object; only meaningful when returned from a supported fold's reducer

Ramda Examples

Example 1 — Official: Collect Until Greater Than 3

The sample from the Ramda docs: build a list and stop at the first item above 3.

Ramda
const upToThree = (acc, item) =>
  item > 3 ? R.reduced(acc) : acc.concat(item);

console.log(R.reduce(upToThree, [], [1, 2, 3, 4, 5]));
// [1, 2, 3]
Try It Yourself

How It Works

  1. Normal steps. 1, 2, and 3 are not above 3, so concat adds each to a new array.
  2. Trigger. 4 > 3 is true, so the reducer returns R.reduced(acc) with acc = [1, 2, 3].
  3. Stop. R.reduce sees the wrapper, unwraps it, and ends the loop.
  4. Skipped. 4 is not added (we wrapped the old acc), and 5 is never visited.

Example 2 — Find the First Match

Return the first number above 10 and stop searching as soon as it is found.

Ramda
const firstOverTen = (found, n) =>
  n > 10 ? R.reduced(n) : found;

console.log(R.reduce(firstOverTen, null, [4, 8, 15, 16, 23]));
// 15
Try It Yourself

How It Works

  1. Seed. found starts as null, meaning “nothing found yet”.
  2. Keep looking. 4 and 8 fail the test, so found stays null.
  3. Found. 15 > 10, so the reducer returns R.reduced(15) and the search ends.
  4. Only 3 visits. 16 and 23 are skipped. For this exact job, R.find is the ready-made shortcut.

Example 3 — Stop After the Item That Reaches a Target

Wrap the new total so the item that crosses the line is included.

Ramda
const sumToTen = (sum, n) => {
  const next = sum + n;
  return next >= 10 ? R.reduced(next) : next;
};

console.log(R.reduce(sumToTen, 0, [3, 4, 5, 6]));
// 12
Try It Yourself

How It Works

  1. Add first. The reducer computes next before deciding.
  2. Below target. 0 + 3 = 3 and 3 + 4 = 7 are under 10, so they are returned normally.
  3. Reached. 7 + 5 = 12 is at least 10, so it returns R.reduced(12); the 5 is counted.
  4. Compare. Wrapping the old total, R.reduced(sum), would give 7 instead.

Example 4 — Stop on Bad Data

Sum numbers, but return an error message the moment a non-number appears.

Ramda
const safeSum = (total, n) =>
  typeof n !== 'number' ? R.reduced('Invalid: ' + n) : total + n;

console.log(R.reduce(safeSum, 0, [1, 2, 'x', 4]));  // 'Invalid: x'
console.log(R.reduce(safeSum, 0, [1, 2, 3]));       // 6
Try It Yourself

How It Works

  1. Good data. 1 and 2 are numbers, so the total grows to 3.
  2. Bad item. 'x' is a string, so the reducer returns R.reduced('Invalid: x').
  3. Any type. The final value does not have to match the accumulator; here a number sum ends with a string.
  4. Clean list. With no bad items, nothing is wrapped and the full sum 6 is returned.

Example 5 — Same Wrapper in Other Folds

One stopping reducer works in R.reduceRight and R.transduce too.

Ramda
const nums = [1, 2, 3, 4, 5];

console.log(R.reduceRight(
  (n, acc) => acc + n > 10 ? R.reduced(acc) : acc + n,
  0, nums
));  // 9

console.log(R.transduce(
  R.map(R.multiply(2)),
  (acc, n) => acc + n > 10 ? R.reduced(acc) : acc + n,
  0, nums
));  // 6
Try It Yourself

How It Works

  1. reduceRight. Its reducer is (value, acc). From the right: 5, then 9; adding 3 would make 12, so it stops at 9.
  2. transduce. R.map(R.multiply(2)) doubles each item before it reaches the reducer: 2, 4, 6, …
  3. Stop. 2 + 4 = 6; adding 6 would make 12, so R.transduce stops at 6 and never doubles 4 or 5.
  4. Same idea. Each fold unwraps R.reduced the same way.

Browser & Runtime Support

R.reduced() is a tiny plain-JavaScript helper inside Ramda 0.15.0+. It creates an ordinary object and uses no browser API, so support depends only on loading Ramda.

✓ Ramda 0.15.0+ · Any JS runtime

Ramda.js R.reduced()

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.

100% With Ramda 0.15+ 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.reduced() Universal

Bottom line: Safe in any project with Ramda 0.15.0 or later (check with npm ls 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].

Frequently Asked Questions

R.reduced(x) wraps x in a special marker that means 'this is the final answer'. When a reducer returns it inside R.reduce or a related Ramda fold, the loop stops immediately and the unwrapped x becomes the result. The official sample collects [1, 2, 3, 4, 5] until an item is greater than 3 and returns [1, 2, 3].
The Ramda docs list five: R.reduce, R.reduceWhile, R.reduceBy, R.reduceRight, and R.transduce. Other functions such as R.map, R.scan, and native Array.prototype.reduce treat the wrapper as an ordinary object and keep going.
Wrap the new value instead of the old one. Returning R.reduced(acc) stops before the current item; returning R.reduced(acc.concat(item)) or R.reduced(acc + item) stops after adding it.
Both stop a fold early. With R.reduced you decide inside the reducer and can choose the final value. R.reduceWhile takes a separate predicate and always returns the accumulator from before the failing item. Ramda builds reduceWhile with R.reduced internally.
You should not. The Ramda docs say the wrapper is a black box whose internal structure is not guaranteed to stay the same. Only return it from a reducer and let Ramda unwrap it.
No. R.reduced has been a stable Ramda list function since v0.15.0. It is not deprecated, experimental, or non-standard.

Next: R.reduceRight()

Fold a list from the last item to the first.

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