Skip to content

gjohnson/pluck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

pluck off property value(s) from arrays or objects

Resources

Stars

Watchers

Forks

Packages

No packages published