get-object-path

Return a value from given object path

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
get-object-path
2310.0.38 years ago10 years agoMinified + gzip package size for get-object-path in KB

Readme

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.