npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

object.pluck

0.1.2 • Public • Published

object.pluck NPM version

Like pluck from underscore / lo-dash, but returns an object composed of specified properties, with values unmodified from those of the original object.

Install

Install with npm

npm i object.pluck --save

Usage

var pluck = require('object.pluck');
 
var obj = {
  a: {locals : {first: 'Brian'}, options : {foo: true}},
  b: {locals : {last: 'Woodward'}, options : {bar: false}}
};
 
pluck(obj, 'locals');
//=> {a: {first: 'Brian'}, b: {last: 'Woodward'}}
 
pluck(obj, 'options');
//=> {a: {foo: true}, b: {bar: false}}

You can also use property "paths" to get values from nested properties:

var obj = {
  a: {locals : {name: {first: 'Brian'}}},
  b: {locals : {name: {last: 'Woodward'}}}
};
pluck(obj, 'locals.name');
 
//=> {a: {first: 'Brian'}, b: {last: 'Woodward'}}

Run tests

Install dev dependencies

npm i -d && npm test

Author

Jon Schlinkert

License

Copyright (c) 2014-2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb on February 17, 2015.

install

npm i object.pluck

Downloadsweekly downloads

57

version

0.1.2

license

none

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability