Ramda.js R.into() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
List

Definition

R.into(acc, transducer, list) runs a transducer — list steps like R.map, R.filter, and R.take used without a list — over list in one pass. The results go into a fresh value of the same type as acc: an array, a string, or an object (official Ramda docs).

Stable since v0.12.0: R.into is not deprecated, experimental, or non-standard. Warning: the accumulator only picks the result type — anything already inside it is ignored.

Syntax

Call R.into. Start with this line.

Ramda
R.into(acc, transducer, list)
CallWhat it does
R.into(acc, transducer, list)Primary signature.
R.into(...)Call the list helper.

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

Library declarations
Ramda
R.into(acc, transducer, list)

Parameters

ParameterDescription
accRequired. Array, String, or Object. Picks the result type (its contents are ignored)
transducerRequired. Function. The steps, e.g. R.compose(R.map(f), R.take(2))
listRequired. Array or iterable. The input items (only read)

Return Value

Return ValueDescription
*The value returned by R.into().

Ramda Examples

Example 1 — Official Sample

Add 1 to each number and keep the first two, as in the Ramda docs.

Ramda
const numbers = [1, 2, 3, 4];
const transducer = R.compose(R.map(R.add(1)), R.take(2));

console.log(JSON.stringify(R.into([], transducer, numbers))); // [2,3]

const intoArray = R.into([]);
console.log(JSON.stringify(intoArray(transducer, numbers)));  // [2,3]
Try It Yourself

How It Works

  1. Steps. R.map(R.add(1)) and R.take(2) have no list, so R.compose joins them into a transducer.
  2. Result type. [] means “collect into a new array”.
  3. One pass. 1 → 2 and 2 → 3 are kept; then take(2) is full and the loop stops.
  4. Curry. R.into([]) waits for a transducer and a list, so intoArray is reusable.

Example 2 — Same Steps, Array or String

Only the accumulator changes, and so does the shape of the result.

Ramda
const shout = R.map(R.toUpper);
const letters = ['a', 'b', 'c'];

console.log(JSON.stringify(R.into([], shout, letters))); // ["A","B","C"]
console.log(JSON.stringify(R.into('', shout, letters))); // "ABC"
Try It Yourself

How It Works

  1. One transducer. R.map(R.toUpper) is a single step; no compose needed.
  2. Array. With [], each result is pushed onto a new array.
  3. String. With '', each result is added to the end of a new string.
  4. Reuse. The same shout works for both; the steps never know the result type.

Example 3 — Build an Object from Pairs

Keep active users and turn each one into an [id, name] pair.

Ramda
const users = [
  { id: 1, name: 'Ann', active: true },
  { id: 2, name: 'Bob', active: false },
  { id: 3, name: 'Cy', active: true }
];

const activeNames = R.compose(
  R.filter(R.prop('active')),
  R.map(user => [user.id, user.name])
);

console.log(JSON.stringify(R.into({}, activeNames, users))); // {"1":"Ann","3":"Cy"}
Try It Yourself

How It Works

  1. Filter. R.prop('active') drops Bob first.
  2. Map. Each remaining user becomes a pair like [1, 'Ann'].
  3. Object. With {}, each pair is merged in as key: value.
  4. Keys. Object keys are always strings, so 1 shows as "1".

Example 4 — It Stops Early

Count how many times the mapping function runs on a list of 1000 numbers.

Ramda
let calls = 0;
const times10 = R.map(n => { calls += 1; return n * 10; });
const nums = R.range(1, 1001); // 1 to 1000

calls = 0;
const a = R.take(2, times10(nums));
console.log('map then take:', JSON.stringify(a), calls); // map then take: [10,20] 1000

calls = 0;
const b = R.into([], R.compose(times10, R.take(2)), nums);
console.log('into:', JSON.stringify(b), calls);          // into: [10,20] 2
Try It Yourself

How It Works

  1. Two uses. times10(nums) maps a whole array; inside compose the same times10 acts as a transducer.
  2. map then take. All 1000 numbers are mapped into a new array, then R.take keeps two.
  3. into. Each number goes through map and take together; after two, take is full and the loop stops.
  4. Same answer. Both give [10,20], but into did 2 calls instead of 1000.

Example 5 — Steps Run Left to Right

Swap the order of the same two steps and the answer changes.

Ramda
const isEven = n => n % 2 === 0;
const numbers = [1, 2, 3, 4];

const mapFirst = R.compose(R.map(R.add(1)), R.filter(isEven));
const filterFirst = R.compose(R.filter(isEven), R.map(R.add(1)));

console.log(JSON.stringify(R.into([], mapFirst, numbers)));    // [2,4]
console.log(JSON.stringify(R.into([], filterFirst, numbers))); // [3,5]
Try It Yourself

How It Works

  1. mapFirst. Add 1 first: [2, 3, 4, 5]; then keep evens: [2, 4].
  2. filterFirst. Keep evens first: [2, 4]; then add 1: [3, 5].
  3. Why. Each transducer wraps the next, so the leftmost step sees each item first.
  4. Tip. Read a transducer compose like R.pipe: top to bottom, left to right.

Browser & Runtime Support

R.into() has been in Ramda since v0.12.0. Arrays and strings work in any JavaScript engine; using a Set, Map, or generator as the list needs ES2015 iterators.

✓ Ramda 0.12.0+ · Any JS runtime

Ramda.js R.into()

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.12+ 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.into() Universal

Bottom line: Safe in any project with Ramda 0.12.0 or later. The closest native one-pass pipeline is the ES2025 iterator helpers, such as Iterator.prototype.take(): Chrome 122+, Firefox 131+, Safari 18.4+, Node 22+. These labs load [email protected].

Frequently Asked Questions

R.into(acc, transducer, list) runs a transducer over the list and collects the results. The accumulator only picks the result type: [] gives an array, '' gives a string, and {} gives an object.
A transducer is a list step such as R.map(fn), R.filter(pred), or R.take(n) used without a list. Several can be joined with R.compose, and R.into then runs them all in a single pass over the list.
Each transducer wraps the next step. In R.compose(R.map(f), R.take(2)), map receives each item first and passes the result on to take. So the order reads left to right, the opposite of normal R.compose.
R.into picks the reducing step from the accumulator type and always starts empty. R.transduce(xf, fn, acc, list) takes your own reducing function and keeps acc as the real starting value.
No. It starts from a fresh empty array, string, or object, and the list is only read. R.into([1], R.map(R.inc), [2]) returns [3], and the [1] you passed is not changed or used.
No. R.into has been a stable Ramda List function since v0.12.0. It is not deprecated, experimental, or non-standard.

Next: R.join()

Join list items into one string with a separator.

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