https://github.com/serapath/getval
read values from nested object like from a flat key value store
https://github.com/serapath/getval
Last synced: about 4 hours ago
JSON representation
read values from nested object like from a flat key value store
- Host: GitHub
- URL: https://github.com/serapath/getval
- Owner: serapath
- License: mit
- Created: 2015-04-08T22:52:05.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2017-03-12T21:39:39.000Z (over 9 years ago)
- Last Synced: 2025-10-29T04:37:25.767Z (8 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/getval
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# getval
read values from nested object like from a flat key value store
# usage
`npm install getval`
```js
var getval = require('getval')
var state = { '': 3, a: { b: [5,6,7], '': { '': 15 } } }
console.log('state =',state)
console.log(getval(state)) // => { '': 3, a: { b: [5,6,7], '': { '': 15 } } }
console.log(getval(state, 'a//')) // => 15
console.log(getval(state, '')) // => 3
console.log(getval(state, ['a','b'])) // => [5,6,7]
console.log(getval(state, 'a/b')) // => [5,6,7]
console.log(getval(state, 'a.b', '.')) // => [5,6,7]
console.log(getval(state, 'a/b/0')) // => 5
```
# related
* see [setval](https://www.npmjs.com/package/setval)