Ramda’s R.project() answers a table question: keep these columns on every row. You pass a list of property names, then a list of objects. You get a new array of new objects. Native JavaScript is usually rows.map((row) => Object.fromEntries(names.map((k) => [k, row[k]]))). project is data-last, so R.project(['name', 'grade']) is already a function of one table — ready for R.pipe.
The official sample is the whole idea. Abby has name, age, hair, and grade. Fred has the same shape. R.project(['name', 'grade'], kids) is [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]. That is a SQL SELECT name, grade FROM kids. Need one object? That is R.pick. Need holes for missing names? That is already baked in: project is R.map of R.pickAll. Need a column of values? That is R.pluck.
Syntax
Call R.project. Start with this line.
Ramda
R.project(names, list)
Call
What it does
R.project(names, list)
Primary signature.
R.project(...)
Call the object helper.
Prefer import { project } from "ramda" when you want a named import.
Library declarations
Ramda
R.project(names, list)
Parameters
Parameter
Description
names (docs: props)
Required. Array. The property names to keep on every row. Order in the leftover follows this list.
list (docs: objs)
Required. Array. The objects to query. Each row is copied; the source array and objects are never mutated.
Return Value
Return Value
Description
Array
A new array of new objects, each with just the listed keys. Missing names are still present as undefined because the implementation maps R.pickAll. An empty list yields []. An empty names list yields an empty object per row.
Ramda Examples
📚 Getting Started
The official kids table, then what happens when a listed column is missing.
Example 1 — Official Kids Columns
Keep name and grade on every row. age and hair leave.
Because project is arity 2, filling names leaves a function of one list. Nested profile is copied by reference. Clone it (or use R.clone) if later writes must not leak.
Example 5 — Empty Names, Empty List, One Column
No columns yields {} per row. No rows yields []. One name still returns objects, not a pluck array.
pickAll([], row) is {}, so two empty objects come back. Need [7, 12] instead of [{age: 7}, {age: 12}]? That is R.pluck('age', kids).
Compatibility
Browser Support
R.project() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.1.0+ · Any JS runtime
Ramda.js R.project()
Load Ramda 0.1.0 or later via CDN or npm, then call R.project with a names list and an array of objects. No extra browser API is required.
100%With Ramda 0.1.0+
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.project()Universal
Bottom line: Safe in any project that includes Ramda 0.1.0 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.project(names, list) maps R.pickAll(names) over a list of objects. Each leftover is a new object with only the listed keys. Added in v0.1.0. The original rows are not mutated. Ramda calls it a reasonable analog to SQL SELECT.
With kids Abby and Fred, R.project(['name', 'grade'], kids) is [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]. age and hair are dropped on every row.
pick works on one object. project is pickAll mapped over a list. pluck returns an array of one property's values. props returns an array of values from one object. project always returns an array of objects.
project uses pickAll, so missing names still appear as undefined. JSON.stringify drops those keys. Use pick mapped over the list if you want missing names omitted.
No. Each leftover is a new object. Nested values are copied by reference, so the copy is shallow.
No. R.project is a stable Ramda object helper from v0.1.0. It is not deprecated, experimental, or non-standard.