1.0.6 • Published 6 years ago

object-path-resolve v1.0.6

Weekly downloads
91
License
MIT
Repository
github
Last release
6 years ago

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 the path (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'

License

MIT

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago