Skip to content

damianc/obj-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

ObjPath

Getting object property by a path string.

Installation

npm i @damianc/obj-path

Use

const obj = {
  foo: {
  bar: [10, 20, 30, 40]
  }
}

ObjPath(obj, 'foo.bar[1]')
// 20
const obj = {
  foo: {
    bar: [
      120,
      { baz: [{
        quux: 200
      }] }
    ]
  }
};

ObjPath(obj, 'foo.bar[1].baz[0].quux')
// 200
const obj = {
  foo: [1, 2, [3, 4]]
};

ObjPath(obj, 'foo[2][0]')
// 3

About

Getting object property by a path string.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published