Bump to v4.13.0.

This commit is contained in:
John-David Dalton
2016-05-21 01:14:43 -07:00
parent dbe6a9008c
commit 0cf3476f14
108 changed files with 1169 additions and 896 deletions

View File

@@ -1,5 +1,9 @@
var baseFindIndex = require('./_baseFindIndex'),
baseIteratee = require('./_baseIteratee');
baseIteratee = require('./_baseIteratee'),
toInteger = require('./toInteger');
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
/**
* This method is like `_.find` except that it returns the index of the first
@@ -12,6 +16,7 @@ var baseFindIndex = require('./_baseFindIndex'),
* @param {Array} array The array to search.
* @param {Array|Function|Object|string} [predicate=_.identity]
* The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
*
@@ -36,10 +41,16 @@ var baseFindIndex = require('./_baseFindIndex'),
* _.findIndex(users, 'active');
* // => 2
*/
function findIndex(array, predicate) {
return (array && array.length)
? baseFindIndex(array, baseIteratee(predicate, 3))
: -1;
function findIndex(array, predicate, fromIndex) {
var length = array ? array.length : 0;
if (!length) {
return -1;
}
var index = fromIndex == null ? 0 : toInteger(fromIndex);
if (index < 0) {
index = nativeMax(length + index, 0);
}
return baseFindIndex(array, baseIteratee(predicate, 3), index);
}
module.exports = findIndex;