https://github.com/azer/get-object-path
Return the value at given object path.
https://github.com/azer/get-object-path
Last synced: 11 months ago
JSON representation
Return the value at given object path.
- Host: GitHub
- URL: https://github.com/azer/get-object-path
- Owner: azer
- Created: 2014-02-01T00:14:22.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2016-03-23T07:36:47.000Z (about 10 years ago)
- Last Synced: 2024-05-02T06:04:00.948Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 23
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## get-object-path
Return the value at given object path.
## Install
```bash
$ npm install azer/get-object-path
```
## Usage
```js
var get = require('get-object-path')
var context = {
foo: 'bar',
qux: {
hello: 'world',
eggs: [
'white egg',
'brown egg'
],
'delicious fruits :)': [
'grape',
'orange',
'carrot'
]
}
}
get(context, 'foo')
// => 'bar'
get(context, 'qux.hello')
// => world
get(context, 'qux.eggs[0]')
// => white egg
get(context, 'qux.eggs[1]')
// => brown egg
get(context, 'qux.delicious fruits :)[1]')
// => orange
```
See `test.js` for more info.