xpick
v1.0.3
Published
Extremely powerful pick functionality
Downloads
4
Readme
Xpick
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 !