Urara-Blog/node_modules/.pnpm-store/v3/files/48/36f091b72329dbed36e1986b16df62ba836d681c9c52622688387513e51bc57e772d5609f99c96d15d59a4c3808d6d7ae4cf91e7f1f4231ebc96704ac7faa9
2022-08-14 01:14:53 +08:00

24 lines
766 B
Text

/**
* The base implementation of `_.findIndex` and `_.findLastIndex` without
* support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {number} fromIndex The index to search from.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseFindIndex(array, predicate, fromIndex, fromRight) {
var length = array.length,
index = fromIndex + (fromRight ? 1 : -1);
while ((fromRight ? index-- : ++index < length)) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
module.exports = baseFindIndex;