MCPcopy
hub / github.com/jashkenas/underscore / createPredicateIndexFinder

Function createPredicateIndexFinder

underscore-node-f.cjs:1270–1280  ·  view source on GitHub ↗
(dir)

Source from the content-addressed store, hash-verified

1268
1269// Internal function to generate `_.findIndex` and `_.findLastIndex`.
1270function createPredicateIndexFinder(dir) {
1271 return function(array, predicate, context) {
1272 predicate = cb(predicate, context);
1273 var length = getLength(array);
1274 var index = dir > 0 ? 0 : length - 1;
1275 for (; index >= 0 && index < length; index += dir) {
1276 if (predicate(array[index], index, array)) return index;
1277 }
1278 return -1;
1279 };
1280}
1281
1282// Returns the first index on an array-like that passes a truth test.
1283var findIndex = createPredicateIndexFinder(1);

Callers 1

Calls 2

predicateFunction · 0.85
cbFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…