birds-eye
object or array with nesting → collection containing all primitive value types and corresponding nest depths
Install
npm install --save birds-eye
Usage
Object with nesting:
const obj = i: MathE n * n k: l: true m: n: o: p: q: 'Q' r: null s: 42
Nested structure of the object's primitive values:
console; // => type: 'number' depth: 0 type: 'boolean' depth: 1 type: 'string' depth: 4 type: 'null' depth: 2 type: 'number' depth: 0
Return all primitive types found at a given depth of nesting:
console; // => ['number', 'number']console; // => []
This of course also works with nested arrays:
const arr = 242true'n'1e6 undefined;console; // => type: 'number' depth: 0 type: 'number' depth: 1 type: 'boolean' depth: 4 type: 'string' depth: 1 type: 'number' depth: 2 type: 'undefined' depth: 0
API
birdsEye(obj)
Arguments
obj
- object|array to map to a one dimensional collection
birdsEye.atDepth(obj, n)
Arguments
obj
- same as aboven
- the nest depth that the resulting collection should be filtered by
License
MIT © Kevin Donahue