Ramda’s R.paths() answers several nested questions at once: what values sit at these trails? You pass an array of path arrays, then the object. You get a list of leftovers in the same order. Native JavaScript would repeat optional chaining: [obj?.a?.b, obj?.p?.[0]?.q]. That is data-first. paths is data-last, so R.paths([['user', 'name'], ['user', 'id']]) is already a function of one object — ready for R.map or R.pipe.
The official sample is the whole idea. R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}) is [2, 3]. Swap the second trail for ['p', 'r'] and the leftover is [2, undefined]. Need one trail? That is R.path. Need a default on one trail? That is R.pathOr. Need several top-level keys only? That is R.props.
Syntax
Call R.paths. Start with this line.
Ramda
R.paths(pathsArray, obj)
Call
What it does
R.paths(pathsArray, obj)
Primary signature.
R.paths(...)
Call the object helper.
Prefer import { paths } from "ramda" when you want a named import.
Library declarations
Ramda
R.paths(pathsArray, obj)
Parameters
Parameter
Description
pathsArray
Required. Array of arrays. Each inner array is a path for R.path. An empty outer list returns []. An empty inner path returns obj in that slot.
obj
Required. Object or Array. The source shared by every trail. null and undefined yield undefined in every slot that walks. The source is never mutated.
Return Value
Return Value
Description
Array
One leftover per inner path, in order. A missing node or stored undefined is undefined in that slot. Length matches pathsArray.length.
Ramda Examples
📚 Getting Started
The official two-trail sample, then the same helper with extra array indexes.
Example 1 — Official Two Nested Paths
Both trails hit. Then the second trail misses and that slot is undefined.
The first inner path walks a then b. The second walks p, index 0, then q. p has no key r, so only that slot is empty. Native obj.p.r would throw. That is the docs sample from ramdajs.com.
Example 2 — Array Indexes and Negatives
Each inner path can mix object keys and list indexes, including negatives through R.nth.
Index 0 is the first item. -1 is the last. Index 9 is off the list, so that one-item leftover is [undefined]. Pass numbers, not '0', so the walk uses nth.
📈 Practical Patterns
Compare cousins, then a curried helper, then empty lists and dotted-string pitfalls.
Example 3 — vs path and props
path unwraps one leftover. paths keeps the array. props only reads top-level keys.
paths([['a', 'b']], obj) is [R.path(['a', 'b'], obj)]. props cannot reach p[0].q; it only looks at own top-level names. Mix one-segment and nested trails in the same pathsArray when you need both.
Example 4 — Curry and Map
Fill the path list to map over rows. A missing y leaves undefined in that pair.
Because paths is arity 2, filling the path list leaves a function of one object. Each row becomes a two-item leftover. For a named fallback, map R.pathOr instead, or run R.map(R.defaultTo(0), pair) after the fact.
Example 5 — Empty Paths, Dotted String, Stored Undefined
An empty outer list is []. An empty inner path returns the object. A dotted string is one literal key. A stored undefined looks like a miss.
No inner paths means no leftovers. An empty inner array never walks, so you get the input back in that slot. ['user.name'] looks for a key whose name includes a dot. Split it: ['user', 'name']. Use R.hasPath when a stored hole must count as present.
Compatibility
Browser Support
R.paths() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.27.1+ · Any JS runtime
Ramda.js R.paths()
Load Ramda 0.27.1 or later via CDN or npm, then call R.paths with a list of path arrays and an object. No extra browser API is required.
100%With Ramda 0.27.1+
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
R.paths()Universal
Bottom line: Safe in any project that includes Ramda 0.27.1 or later. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node. These labs use [email protected].
Frequently Asked Questions
R.paths(pathsArray, obj) walks every inner path and returns a list of leftovers in the same order. A miss is undefined in that slot. Added in v0.27.1.
R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}) is [2, 3]. The same object with ['p', 'r'] in the second path is [2, undefined].
path walks one trail and returns one value. paths walks many trails and always returns an array. props reads several top-level keys only; each name is one key, not a nested path.
No. A missing segment, null, or undefined along a trail puts undefined in that slot. Other trails still run. Native obj.a.b would throw.
paths itself has no default. Map pathOr, or map defaultTo over the leftover list. R.pathOr(d, path, obj) is the one-trail cousin with a fallback.
No. R.paths is a stable Ramda object helper from v0.27.1. It is not deprecated, experimental, or non-standard.