var globObject = require('{%= name %}');
globObject('a.*.f', {a: {b: {c: 'd'}, e: {f: 'g'}}});
//=> { a: { e: { f: 'g' } } }
Given the following object:
var obj = {
a: {
b: {
c: 'd',
e: 'f',
g: 'h',
i: {j: 'k'},
l: {g: 'k'}
},
i: 'j'
}
};
globObject('*', obj);
//=> obj (matches all keys)
globObject('a.*.{c,e}', obj);
//=> {a: {b: {c: 'd', e: 'f'}}}
A single star will match one level of the object:
globObject('a.*.g', obj);
//=> {a: {b: {g: 'h'}}}
A double star will match to any depth (note that the single star in the previous example did not match a.b.l.g
):
globObject('a.**.g', obj);
//=> {a: {b: {g: 'h', l: {g: 'k'}}}}