yiwn-choose

0.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i yiwn-choose

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • antaranian