A 200b (gzipped) utility function to resolve object properties with string paths
Retrieve a value from the
obj
based on thepath
(accepts dot and bracket notation)
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'