mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
22 lines
586 B
JavaScript
22 lines
586 B
JavaScript
import baseCallback from './baseCallback';
|
|
import baseFindIndex from './baseFindIndex';
|
|
|
|
/**
|
|
* Creates a `_.findIndex` or `_.findLastIndex` function.
|
|
*
|
|
* @private
|
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
* @returns {Function} Returns the new find function.
|
|
*/
|
|
function createFindIndex(fromRight) {
|
|
return function(array, predicate, thisArg) {
|
|
if (!(array && array.length)) {
|
|
return -1;
|
|
}
|
|
predicate = baseCallback(predicate, thisArg, 3);
|
|
return baseFindIndex(array, predicate, fromRight);
|
|
};
|
|
}
|
|
|
|
export default createFindIndex;
|