Bump to v4.13.0.

This commit is contained in:
John-David Dalton
2016-05-18 16:00:35 -07:00
parent 07c844053e
commit 35cdf6513b
513 changed files with 2603 additions and 2423 deletions

View File

@@ -1,5 +1,9 @@
import baseFindIndex from './_baseFindIndex';
import baseIteratee from './_baseIteratee';
import baseFindIndex from './_baseFindIndex.js';
import baseIteratee from './_baseIteratee.js';
import toInteger from './toInteger.js';
/* 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 @@ import baseIteratee from './_baseIteratee';
* @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 @@ import baseIteratee from './_baseIteratee';
* _.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);
}
export default findIndex;