Ramda.js R.unapply() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

An adapter for functions that take one array. R.unapply(fn) returns a new function that accepts any number of separate arguments, packs them into an array, and passes that array to fn — like rest parameters without writing the arrow function yourself.

Status: stable since Ramda v0.8.0 — not deprecated, experimental, or non-standard.

Syntax

Call R.unapply. Start with this line.

Ramda
R.unapply(fn)
CallWhat it does
R.unapply(fn)Primary signature.
R.unapply(...)Call the function helper.

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

Library declarations
Ramda
R.unapply(fn)

Parameters

ParameterDescription
fnRequired. A function that takes one array

Return Value

Return ValueDescription
*A function that takes any number of arguments and calls fn([...args])

Ramda Examples

Example 1 — Official: JSON.stringify

Three loose numbers become one array, which is turned into a JSON string.

Ramda
const toJson = R.unapply(JSON.stringify);

console.log(toJson(1, 2, 3));
// → '[1,2,3]'
Try It Yourself

How It Works

  1. Wrap. R.unapply(JSON.stringify) returns toJson.
  2. Pack. toJson(1, 2, 3) collects the values into [1, 2, 3].
  3. Call. JSON.stringify receives that single array.
  4. Result. The string '[1,2,3]'.

Example 2 — See the Packed Array

With R.identity you get the array itself — a handy way to see what unapply builds.

Ramda
const pack = R.unapply(R.identity);

console.log(pack(1, 2, 3));
// → [1, 2, 3]

console.log(pack());
// → []
Try It Yourself

How It Works

  1. Identity. R.identity returns whatever it receives.
  2. Three args. They are packed into [1, 2, 3] and returned as-is.
  3. No args. The packed array is simply empty: [].

Example 3 — Sum Loose Numbers

R.sum wants an array. Unapply lets you pass the numbers one by one.

Ramda
const total = R.unapply(R.sum);

console.log(total(1, 2, 3));
// → 6

console.log(total());
// → 0
Try It Yourself

How It Works

  1. Wrap. total is R.sum with loose-argument input.
  2. Pack. total(1, 2, 3) calls R.sum([1, 2, 3]), which is 6.
  3. Empty. total() calls R.sum([]), which is 0.

Example 4 — unapply vs apply

They work in opposite directions: apply spreads an array, unapply packs arguments.

Ramda
const maxOf = R.apply(Math.max);   // array → arguments
const sumOf = R.unapply(R.sum);    // arguments → array

console.log(maxOf([1, 9, 4]));
// → 9

console.log(sumOf(1, 9, 4));
// → 14
Try It Yourself

How It Works

  1. apply. R.apply(Math.max) turns [1, 9, 4] into Math.max(1, 9, 4) → 9.
  2. unapply. R.unapply(R.sum) turns 1, 9, 4 into R.sum([1, 9, 4]) → 14.
  3. Rule. If fn takes separate values, use apply; if it takes one array, use unapply.

Example 5 — A Variadic Helper from a Pipe

Wrap a whole pipe so callers can pass as many name parts as they like.

Ramda
const fullName = R.unapply(
  R.pipe(R.filter(Boolean), R.join(" "))
);

console.log(fullName("Ada", "", "Lovelace"));
// → "Ada Lovelace"

console.log(fullName("Grace"));
// → "Grace"
Try It Yourself

How It Works

  1. Pack. The name parts become one array, e.g. ["Ada", "", "Lovelace"].
  2. Filter. R.filter(Boolean) drops empty strings.
  3. Join. R.join(" ") glues the rest with spaces.
  4. Any count. One part or many — the R.pipe always gets an array.

Browser & Runtime Support

R.unapply has been in Ramda since v0.8.0. Ramda’s browser build is plain ES5, so it runs in any modern browser and in Node.js / Bun / Deno with npm install ramda.

✓ Stable · Ramda 0.8.0+

R.unapply()

Built on the plain arguments object, so no special browser API is needed. The examples use ES2015 const, supported by every evergreen browser.

100% With Ramda 0.8.0+
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.unapply Ramda 0.8.0+

Bottom line: Safe for production with Ramda 0.8.0 or newer. The labs on this page use [email protected].

Frequently Asked Questions

R.unapply(fn) takes a function that expects one array and returns a new function that accepts any number of separate arguments. Those arguments are packed into an array and passed to fn, so R.unapply(fn)(a, b) is fn([a, b]). Docs sample: R.unapply(JSON.stringify)(1, 2, 3) //=> '[1,2,3]'.
They are inverses. R.apply(fn, [a, b]) calls fn(a, b) — it spreads an array into arguments. R.unapply(fn)(a, b) calls fn([a, b]) — it packs arguments into an array.
It does the same job. R.unapply(fn) behaves like (...args) => fn(args). Use unapply when you want a point-free, reusable adapter for an existing list function such as R.sum or R.join.
fn receives an empty array. R.unapply(R.sum)() is 0 and R.unapply(JSON.stringify)() is '[]'.
No. It gathers every argument from one call and runs immediately. R.unapply(R.sum)(1) returns 1 right away; it does not wait for more arguments. Its length is 0.
No. R.unapply has been a stable Ramda function helper since v0.8.0 — not deprecated, experimental, or non-standard.

Next: R.unary()

Learn how to make a function ignore every argument except the first.

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