Access subtree elements using keypath, with wildcard ('*') support.
npm install object-path-wildobject-path-wild
==================
Access subtree elements using keypath, with wildcard ('\*') support.
javascript
'use strict';
const lookup = require('object-path-wild');
const obj = {
a: { b: { c: { d: { e: [
{ f: { g: { h: { i: { j: 'This'}}}}},
{ f: { g: { h: { i: { j: 'is'}}}}},
{ f: { g: { h: { i: { j: 'mad'}}}}},
{ f: { g: { h: { i: { j: 'deep'}}}}}
]}}}};
};
lookup(obj, 'a.b.c.d.e.*.f.g.h.i.j');
// ['This', 'is', 'mad', 'deep'];
``
$3
Any key/idx that is not present along the subtree will be omitted.
``javascript
const obj = {
a: { b: { c: { d: { e: [
{ f: { g: { h: { i: { j: 'Hello!'}}}}},
{ f: { g: { h: 1 }}},
{ f: { g: { h: 2 }}},
{ f: { g: { h: 3 }}}
]}}}};
};
lookup(obj, 'a.b.c.d.e.*.f.g.h.i.j');
// ['Hello!']
```