1.0.3 • Published 4 years ago

xpick v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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 !