keyarray-get
v1.0.0
Published
get nested properties with key arrays
Downloads
6,335
Maintainers
Readme
var get = require('keyarray-get')
var assert = require('assert')
assert(get({a: 'value'}, ['a']) === 'value')
assert(get({a: {b: 'value'}}, ['a', 'b']) === 'value')
assert(get({a: {b: ['value']}}, ['a', 'b', 0]) === 'value')
assert.throws(function () {
get({}, null)
}, TypeError)
assert.throws(function () {
get(null, [0])
}, TypeError)
assert(get({}, ['a']) === undefined)
assert(get({}, ['a'], 'surrogate') === 'surrogate')