pokeprop
v1.0.0
Published
Pick multiples properties from JSON
Downloads
36,964
Readme
Pick multiples properties from JSON
Install
$ npm install --save pokeprop
Usage
const pokeprop = require('pokeprop')
const object = {
company: {
facebook: {
ceo: 'Mark Zuckerberg',
products: ['facebook', 'instagram', 'oculus rift']
},
microsoft: {
ceo: 'Satya Nadella',
products: ['Office', 'windows', 'xbox']
}
},
products: {
games: ['oculus rift', 'xbox'],
network: ['facebook', 'instagram']
}
}
const pickedPropsObject = pokeprop([
'company.facebook.products',
'products.games',
'company.microsoft.ceo'
], object)
// Also it's possible to use pokeprop([paths])(object)
// Output:
// pickedPropsObject = {
// company: {
// facebook: {
// products: ['facebook', instagram', 'oculus rift']
// },
// microsoft: {
// ceo: ['Satua Nadella']
// }
// },
// products: {
// games: ['oculus rift', 'xbox']
// }
// }
License
MIT © Vitor Abner