Skip to content

johnsylvain/object-path-resolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Utility function for resolving object paths

Resources

License

Stars

Watchers

Forks

Packages

No packages published