get-object-path

0.0.3 • Public • Published

get-object-path

Return the value at given object path.

Install

$ npm install get-object-path

Usage

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.

Readme

Keywords

Package Sidebar

Install

npm i get-object-path

Weekly Downloads

421

Version

0.0.3

License

BSD

Last publish

Collaborators

  • hassoncs