object-path-resolve
v1.0.6
Published
Utility function to resolve object paths
Downloads
7
Readme
object-path-resolve
A 200b (gzipped) utility function to resolve object properties with string paths
API
resolve(obj: Object, path: String)
Retrieve a value from the
obj
based on thepath
(accepts dot and bracket notation)
Usage
import resolve from 'object-path-resolve'
const obj = {
prop: { name: 'John' },
arr: [
'one', 'two', 'three'
]
}
resolve(obj, 'prop.name') // => 'John'
resolve(obj, 'prop.age') // => undefined
resolve(obj, 'arr[1]') // => 'two'