Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gcdurastanti/js-extract
Fancy extractor for js objects
https://github.com/gcdurastanti/js-extract
Last synced: 3 months ago
JSON representation
Fancy extractor for js objects
- Host: GitHub
- URL: https://github.com/gcdurastanti/js-extract
- Owner: gcdurastanti
- License: mit
- Created: 2019-03-09T02:50:06.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T03:18:58.000Z (over 1 year ago)
- Last Synced: 2024-07-19T18:24:01.773Z (4 months ago)
- Language: JavaScript
- Size: 217 KB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
```javascript
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:**
```javascript
{
one: {
str: 'one'
},
two: {
num: 2,
foo: {
bar: 'baz'
}
}
}
```