yiwn-choose
v0.0.1
Published
Create and return clone of provided object by including or excluding given properties.
Readme
choose
Create and return clone of provided object by including or excluding given properties.
Installation
Using component
$ component install yiwn/chooseUsing npm for browserify
$ npm install yiwn-chooseUsage
Example:
var choose = require('yiwn-choose');
var obj = {
a: 1,
b: 2,
c: 3
};
choose(obj, ['a', 'b']); // -> { a: 1, b: 2 }
choose(obj, ['a', 'b'], false); // -> { c: 3 }It also provides shortcuts for picking and omitting, which support individual arguments as keys.
choose.pick(obj, 'a', 'b'); // -> { a: 1, b: 2 }
choose.omit(obj, 'a'); // -> { b: 2, c: 3 }Test
Run tests with mocha-phantomjs
$ make testOrigins
Replacement for Lo-Dash's _.pick and _.omit.
License
The MIT License
