Check if an object or it's descendants fullfill a predicate
npm install underscore.has-inside
_.mixin(require('underscore.has-inside'));
Checks a predicate for an object and its descendant
var obj = {
foo: 'bar',
moo: {
boo: 'poo'
},
arrrr: [1,2,3,4]
};
_.findInside(obj, function(item) {
return item.boo && item.boo === 'poo';
}); // -> true
Check if an object or it's descendants have a property
var obj = {
foo: 'bar',
moo: {
boo: 'poo'
},
arrrr: [1,2,3,4]
};
_.hasInside(obj, 'boo'); // -> true
_.hasInside(obj, 'bar'); // -> false