get-in
v3.0.1
Published
get value of nested associative structure given array of keys
Downloads
21
Maintainers
Readme
get-in
get value of nested associative structure given array of keys
inspired by clojure.core/get-in.
code stolen from micro-js/get-prop.
install
with npm, do:
npm i --save get-in
usage
var getIn = require('get-in')
var obj = { foo: { bar: 'baz' } }
getIn(obj, ['foo', 'bar']) // => 'baz'
getIn(obj, ['foo']) // => { bar: 'baz' }
getIn(obj, ['ping']) // => undefined
getIn(obj, ['ping'], 'pong') // => 'pong'
api
getIn(object, path, default)
object
- object to retrieve value frompath
- array specifying pathdefault
- default value if none found
Returns: value
license
ISC