I have simple function to return me object which meets my criteria.
Code looks like:
var res = _.find($state.get(), function(i) {
var match = i.name.match(re);
return match &&
(!i.restrict || i.restrict($rootScope.user));
});
How can I find all results (not just first) which meets this criteria but all results.
Thanks for any advise.
Just use _.filter
- it returns all matched items.
Iterates over elements of collection, returning an array of all elements predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).