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

20
find.js
View File

@@ -1,8 +1,6 @@
var baseEach = require('./_baseEach'),
baseFind = require('./_baseFind'),
baseFindIndex = require('./_baseFindIndex'),
baseIteratee = require('./_baseIteratee'),
isArray = require('./isArray');
var findIndex = require('./findIndex'),
isArrayLike = require('./isArrayLike'),
values = require('./values');
/**
* Iterates over elements of `collection`, returning the first element
@@ -16,6 +14,7 @@ var baseEach = require('./_baseEach'),
* @param {Array|Object} collection The collection to search.
* @param {Array|Function|Object|string} [predicate=_.identity]
* The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {*} Returns the matched element, else `undefined`.
* @example
*
@@ -40,13 +39,10 @@ var baseEach = require('./_baseEach'),
* _.find(users, 'active');
* // => object for 'barney'
*/
function find(collection, predicate) {
predicate = baseIteratee(predicate, 3);
if (isArray(collection)) {
var index = baseFindIndex(collection, predicate);
return index > -1 ? collection[index] : undefined;
}
return baseFind(collection, predicate, baseEach);
function find(collection, predicate, fromIndex) {
collection = isArrayLike(collection) ? collection : values(collection);
var index = findIndex(collection, predicate, fromIndex);
return index > -1 ? collection[index] : undefined;
}
module.exports = find;