1.0.10 • Published 9 years ago
birds-eye v1.0.10
birds-eye
object or array with nesting → collection containing all primitive value types and corresponding nest depths
Install
npm install --save birds-eyeUsage
Object with nesting:
const obj = {
i: Math.E,
j: (n) => n * n,
k: {
l: true,
m: [],
n: {
o: {
p: {
q: 'Q'
}
},
r: null
}
},
s: 42
}Nested structure of the object's primitive values:
console.log(birdsEye(obj));
// =>
[ { 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.log(birdsEye.atDepth(obj, 0)); // => ['number', 'number']
console.log(birdsEye.atDepth(obj, 42)); // => []This of course also works with nested arrays:
const arr = [2,[42,[[[true]]],'n',[1e6]], undefined];
console.log(birdsEye(arr));
// =>
[ { 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
1.0.10
9 years ago
1.0.8
9 years ago
1.0.7
9 years ago
1.0.6
9 years ago
1.0.5
9 years ago
1.0.4
9 years ago
1.0.3
9 years ago
1.0.2
9 years ago
1.0.1
9 years ago
0.3.0
10 years ago
0.2.11
10 years ago
0.2.10
10 years ago
0.2.9
10 years ago
0.2.8
10 years ago
0.2.7
10 years ago
0.2.6
10 years ago
0.2.5
10 years ago
0.2.4
10 years ago
0.2.3
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.4
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago