get-object-path
Return a value from given object path
Last updated 5 years ago by hassoncs .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install get-object-path 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 0.0.3                                ...           latest (5 years ago)

4 Versions

  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
  • 0.0.0                                ...           7 years ago
  • 0.0.3                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 1
Last Month 2
Dependencies (0)
None
Dev Dependencies (1)

Copyright 2014 - 2017 © taobao.org |