* 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.
(array, predicate, fromIndex, fromRight)
| 21725 | * @returns {number} Returns the index of the matched value, else `-1`. |
| 21726 | */ |
| 21727 | function baseFindIndex(array, predicate, fromIndex, fromRight) { |
| 21728 | var length = array.length, |
| 21729 | index = fromIndex + (fromRight ? 1 : -1); |
| 21730 | |
| 21731 | while (fromRight ? index-- : ++index < length) { |
| 21732 | if (predicate(array[index], index, array)) { |
| 21733 | return index; |
| 21734 | } |
| 21735 | } |
| 21736 | return -1; |
| 21737 | } |
| 21738 | |
| 21739 | module.exports = baseFindIndex; |
| 21740 |
no test coverage detected