1.0.1 • Published 6 years ago

property-drill v1.0.1

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

property-drill

Safely find deep properties in objects and arrays.

Installation

With npm:

npm install --save property-drill

Or Yarn:

yarn add property-drill

Usage

var propDrill = require('property-drill')

var obj = {
   a: {
      b: ['c', 'd', 'e']
   }
}

var prop = propDrill(obj, `a`, `b`, 0) // Returns "c"

Why?

While there are tons of modules that do the same thing, many of them do not search within arrays or throw errors if you search deeper than the object is. The ones that meet these requirements take strings as your second argument. This can lead to innaccurate results when mixing objects and arrays and can also be much slower when more powerful regex is used.