mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Bump to v3.6.0.
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
import baseCallback from '../internal/baseCallback';
|
||||
import baseEach from '../internal/baseEach';
|
||||
import baseFind from '../internal/baseFind';
|
||||
import findIndex from '../array/findIndex';
|
||||
import isArray from '../lang/isArray';
|
||||
import createFind from '../internal/createFind';
|
||||
|
||||
/**
|
||||
* Iterates over elements of `collection`, returning the first element
|
||||
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
|
||||
* invoked with three arguments; (value, index|key, collection).
|
||||
* invoked with three arguments: (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for `predicate` the created `_.property`
|
||||
* style callback returns the property value of the given element.
|
||||
@@ -54,13 +51,6 @@ import isArray from '../lang/isArray';
|
||||
* _.result(_.find(users, 'active'), 'user');
|
||||
* // => 'barney'
|
||||
*/
|
||||
function find(collection, predicate, thisArg) {
|
||||
if (isArray(collection)) {
|
||||
var index = findIndex(collection, predicate, thisArg);
|
||||
return index > -1 ? collection[index] : undefined;
|
||||
}
|
||||
predicate = baseCallback(predicate, thisArg, 3);
|
||||
return baseFind(collection, predicate, baseEach);
|
||||
}
|
||||
var find = createFind(baseEach);
|
||||
|
||||
export default find;
|
||||
|
||||
Reference in New Issue
Block a user