0.0.1 • Published 10 years ago

yiwn-choose v0.0.1

Weekly downloads
5
License
MIT
Repository
-
Last release
10 years ago

choose

Create and return clone of provided object by including or excluding given properties.

Installation

Using component

$ component install yiwn/choose

Using npm for browserify

$ npm install yiwn-choose

Usage

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 test

Origins

Replacement for Lo-Dash's _.pick and _.omit.

License

The MIT License