Ramda.js R.partialObject() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Function

Definition

A helper that presets some named fields of a function’s single object argument. Later, you pass the remaining fields; Ramda deep-merges both objects and calls your function once.

Status: added in Ramda v0.28.0 — stable, not deprecated, experimental, or non-standard. Older Ramda versions don’t have it.

Syntax

Call R.partialObject. Start with this line.

Ramda
R.partialObject(f, preset)
CallWhat it does
R.partialObject(f, preset)Primary signature.
R.partialObject(...)Call the function helper.

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

Library declarations
Ramda
R.partialObject(f, preset)

Parameters

ParameterDescription
fRequired. Function that takes a single object
presetRequired. Object of fields to fill in now

Return Value

Return ValueDescription
*New function g(props) → f(merged)

Ramda Examples

Example 1 — Official double

Preset a, pass b later.

Ramda
const multiply2 = ({ a, b }) => a * b;
const double = R.partialObject(multiply2, { a: 2 });

console.log(double({ b: 2 }));
// → 4

console.log(double({ b: 21 }));
// → 42
Try It Yourself

How It Works

  1. One object in. multiply2 reads a and b from a single object.
  2. Preset. double remembers { a: 2 }.
  3. Merge. double({ b: 2 }) builds { a: 2, b: 2 } → 2 * 2 = 4.
  4. Reuse. The preset stays the same for every call → 2 * 21 = 42.

Example 2 — Official Layered Greeting

Build a preset on top of another preset.

Ramda
const greet = ({ salutation, title, firstName, lastName }) =>
  salutation + ", " + title + " " + firstName + " " + lastName + "!";

const sayHello = R.partialObject(greet, { salutation: "Hello" });
const sayHelloToMs = R.partialObject(sayHello, { title: "Ms." });

console.log(sayHelloToMs({ firstName: "Jane", lastName: "Jones" }));
// → "Hello, Ms. Jane Jones!"
Try It Yourself

How It Works

  1. Four fields. greet needs salutation, title, first and last name.
  2. First layer. sayHello fills salutation.
  3. Second layer. sayHelloToMs presets sayHello with title.
  4. Final call. The names complete the object, and greet runs once with all four fields.

Example 3 — Defaults You Can Override

Because the call wins, a preset behaves like a set of default options.

Ramda
const label = ({ text, size, color }) =>
  text + " (" + size + ", " + color + ")";

const button = R.partialObject(label, { size: "md", color: "blue" });

console.log(button({ text: "Save" }));
// → "Save (md, blue)"

console.log(button({ text: "Delete", color: "red" }));
// → "Delete (md, red)"
Try It Yourself

How It Works

  1. Defaults. The preset supplies size: "md" and color: "blue".
  2. Plain call. { text: "Save" } adds only the text → both defaults are used.
  3. Override. color: "red" is in both objects; the call’s value wins.
  4. Untouched. size wasn’t passed, so it stays "md".

Example 4 — Deep Merge of Nested Config

Override one nested field and keep its siblings — something object spread can’t do.

Ramda
const connect = ({ db }) => db.host + ":" + db.port;
const preset = { db: { host: "localhost", port: 5432 } };

const local = R.partialObject(connect, preset);
console.log(local({ db: { port: 6543 } }));
// → "localhost:6543"

console.log(connect({ ...preset, ...{ db: { port: 6543 } } }));
// → "undefined:6543"
Try It Yourself

How It Works

  1. Nested preset. db holds host and port.
  2. Deep merge. Ramda merges inside db: port becomes 6543, host survives.
  3. Spread is shallow. Object spread replaces the whole db object, so host is lost.
  4. Takeaway. Use partialObject when presets contain nested settings.

Example 5 — Reuse a Preset in R.map

A preset function takes one object, so it maps over a list of objects directly.

Ramda
const greet = ({ salutation, firstName }) =>
  salutation + ", " + firstName + "!";

const hello = R.partialObject(greet, { salutation: "Hello" });

const people = [{ firstName: "Jane" }, { firstName: "Ada" }];
console.log(R.map(hello, people));
// → ["Hello, Jane!", "Hello, Ada!"]
Try It Yourself

How It Works

  1. Preset once. hello always supplies salutation: "Hello".
  2. Map. R.map calls hello with each person object.
  3. Merge per item. Each call builds { salutation, firstName } and runs greet.
  4. Safe reuse. The merge creates a new object every time; neither the preset nor people changes.

Browser & Runtime Support

R.partialObject was added in Ramda v0.28.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.28.0+

R.partialObject()

Check your Ramda version first — this helper is missing before 0.28.0. The examples use ES2015 destructuring and arrow functions, supported by every evergreen browser.

100% With Ramda 0.28.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.partialObject Ramda 0.28.0+

Bottom line: Safe for production with Ramda 0.28.0 or newer. On an older pinned version, upgrade Ramda or wrap the function yourself with R.mergeDeepRight. The labs on this page use [email protected].

Frequently Asked Questions

R.partialObject(f, preset) returns a new function g. When you call g(props), Ramda deep-merges preset with props (props wins on conflicts) and calls f with that one merged object. The docs sample: R.partialObject(multiply2, { a: 2 })({ b: 2 }) //=> 4.
R.partial presets leftmost positional arguments from an array: partial(f, [a]). R.partialObject presets named keys of a single object argument: partialObject(f, { a }). Use partialObject when your function takes one options object.
Yes. The merge is mergeDeepRight, so the call's object wins. R.partialObject(multiply2, { a: 2 })({ a: 10, b: 2 }) is 20, not 4. That makes presets behave like overridable defaults.
Plain nested objects merge key by key, so preset.db.host survives when you only pass db.port. Arrays and other values are not merged — the call's value replaces the preset's.
R.partialObject was added in Ramda v0.28.0. In older versions it is undefined, so calling it throws TypeError: R.partialObject is not a function.
No. R.partialObject is a stable Ramda function helper since v0.28.0 — not deprecated, experimental, or non-standard.

Next: R.partialRight()

Learn how to preset the rightmost positional arguments of a function.

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