pluck

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
8
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
2 KB
Returns a new list by plucking the same named property off all objects in the list supplied.
1 contributor
Install pluck as a package?
Copied
npm i @bit/justin-capalbo.ramda.pluck
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
pluck (
key:(Number | String),
f:Array
) : Array

Returns a new list by plucking the same named property off all objects in the list supplied.

pluck will work on any functor in addition to arrays, as it is equivalent to R.map(R.prop(k), f).

Example
var getAges = R.pluck('age');
     getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27]

     R.pluck(0, [[1, 2], [3, 4]]);               //=> [1, 3]
     R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5}
Arguments
key: (Number | String)

The key name to pluck off of each object.

f: Array

The array or functor to consider.

Returns
Array

The list of values for the given key.

Help and resources