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