Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 596 Bytes

README.md

File metadata and controls

26 lines (19 loc) · 596 Bytes

findByPath

Find nested properties in an object by specifying a path, eg "level1.level2.0.name".

var findByPath = require('findByPath'),
obj = {
  level1: true,
  parent: {
    level2: "true"
  }
};

findByPath(obj, 'level1'); // true
findByPath(obj, 'parent.level2'); // "true"
findByPath(obj, 'parent/level2', '/'); // "true"
findByPath(obj, 'parent.child'); // undefined

See tests for more examples.

Contributors

Rodney Rehm contributed the better part of the code to Reol.js. Thanks!