react-collection-helpers
Version:
React Collection Helpers Component
15 lines (11 loc) • 372 B
JavaScript
import applyPredicateToCollectionWith from './apply-predicate-to-collection-with';
function efficientFilter(collection, predicate) {
var matches = [];
for (var i = 0; i < collection.length; i += 1) {
if (predicate(collection[i])) {
matches.push(collection[i]);
}
}
return matches;
}
export default applyPredicateToCollectionWith(efficientFilter);