@gdurastanti/js-extract
v1.0.4
Published
Fancy extractor for js objects
Downloads
1
Readme
js-extract
Fancy extractor for js objects that is like destructuring but safer.
Install
npm install --save @gdurastanti/js-extract
Use
import extract from @gdurastanti/'js-extract'
OR
var extract = require('@gdurastanti/js-extract').default
Example
const data = {
one: {
num: 1,
str: 'one',
foo: {
bar: 'baz',
},
},
two: {
num: 2,
str: 'two',
foo: {
bar: 'baz',
},
}
};
const selector = `
one: {
str
},
two: {
num,
foo
}
`
extract(selector).from(data);
Result:
{
one: {
str: 'one'
},
two: {
num: 2,
foo: {
bar: 'baz'
}
}
}