mirror of
https://github.com/stCarolas/setup-maven.git
synced 2025-01-08 08:35:36 +00:00
19 lines
558 B
JavaScript
19 lines
558 B
JavaScript
|
define(['./_cb', './_getLength'], function (_cb, _getLength) {
|
||
|
|
||
|
// Internal function to generate `_.findIndex` and `_.findLastIndex`.
|
||
|
function createPredicateIndexFinder(dir) {
|
||
|
return function(array, predicate, context) {
|
||
|
predicate = _cb(predicate, context);
|
||
|
var length = _getLength(array);
|
||
|
var index = dir > 0 ? 0 : length - 1;
|
||
|
for (; index >= 0 && index < length; index += dir) {
|
||
|
if (predicate(array[index], index, array)) return index;
|
||
|
}
|
||
|
return -1;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return createPredicateIndexFinder;
|
||
|
|
||
|
});
|