pluck

pluck values from an object path

npm install pluck
1 downloads in the last day
18 downloads in the last week
48 downloads in the last month

Build Status

pluck

pluck property path from arrays or an object.

Installation

component

  $ component install gjohnson/pluck

or

npm

  $ npm install pluck

Example

Pluck from arrays.

var pluck = require('pluck');

var firstName = pluck('name.first');

var items = [
  { name: { first: 'john', last: 'doe' } }
];

var names = firstName(items);

Pluck from plain objects.

var pluck = require('pluck');

var firstName = pluck('name.first');

var item = {
  name: {
    first: 'john',
    last: 'doe'
  }
};

var name = firstName(item);

Pluck using index expressions.

var pluck = require('pluck');

var firstName = pluck('name[1].first');
var item = {
  name: [
    {},
    {
      first: 'john',
      last: 'doe'
    }
  ]
};

var name = firstName(item);

License

MIT

npm loves you