xpick

1.0.3 • Public • Published

Xpick

Build Status npm version npm GitHub license

Extremely powerful pick functionality

Installation

npm install xpick

# or

yarn install xpick

Usage

const pick = require('xpick');

let object = {
  name: 'felix',
  gender: 'male',
  hobbies: [
    { name: 'pingpong', skilled: true }
  ],
  profile: {
    github: 'lyfeyaj',
    twitter: 'lyfeyaj'
  }
};

pick(object, ['name', 'gender']);
// => { name: 'felix', gender: 'male' }

pick(object, 'name');
// => { name: 'felix' }

pick(object, 'name gender profile');
// => { name: 'felix', gender: 'male', profile: { github: 'lyfeyaj', twitter: 'lyfeyaj' } }

pick(object, `
  name
  gender: sex
  profile { twitter }
  hobbies: sports { name }
`);
// => { name: 'felix', sex: 'male', profile: { twitter: 'lyfeyaj' }, sports: [{ name: 'pingpong' }] }

For full xpick syntax support, please check stoc for more information.

Enjoy !

Readme

Keywords

Package Sidebar

Install

npm i xpick

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

5.83 kB

Total Files

6

Last publish

Collaborators

  • lyfeyaj