Skip to content

vweevers/deep-dot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deep-dot

Get a nested property of an object or primitive.

examples

var deep = require('deep-dot')

var obj = {
  a: {
    b: {
      'c.d': [6, '78']
    }
  }
}

// basic usage
console.log(deep(obj, 'a.b.c.d.0') === 6)
console.log(deep(obj, 'a.b.c.d.1.1') === 8)

// attach
obj.deep = deep

// non existent
console.log(obj.deep('x.y') == null)

// array path
console.log(obj.deep(['a', 'b']))

// cute side-effects
console.log(deep('window.location'))
console.log(deep(['a','b','c'], [2]) === 'c')

install

With npm do:

npm install deep-dot

license

MIT

About

Get a nested property of an object or primitive

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published