@ndhoule/pick

2.0.0 • Public • Published

pick CI

Create a shallow copy of an input object that contains only the specified properties.

$ component install ndhoule/pick
$ npm install @ndhoule/pick

API

pick(props : string|string[], object: Object) => Object

Return a shallow copy of an input object containing only a specified list of properties.

var person = { name: 'Tim', occupation: 'enchanter', fears: 'rabbits' };

pick('name', person);
//=> { name: 'Tim' }

pick(['name', 'fears'], person);
//=> { name: 'Tim', fears: 'rabbits' }

License

Released under the MIT license.

Package Sidebar

Install

npm i @ndhoule/pick

Weekly Downloads

94,486

Version

2.0.0

License

MIT

Last publish

Collaborators

  • ndhoule