mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
ESify find implementation.
This commit is contained in:
10
find.js
10
find.js
@@ -26,13 +26,13 @@ import keys from './keys'
|
||||
* // => object for 'barney'
|
||||
*/
|
||||
function find(collection, predicate, fromIndex) {
|
||||
var iterable = Object(collection);
|
||||
const iterable = Object(collection)
|
||||
if (!isArrayLike(collection)) {
|
||||
collection = keys(collection);
|
||||
predicate = function(key) { return iteratee(iterable[key], key, iterable); };
|
||||
collection = keys(collection)
|
||||
predicate = (key) => iteratee(iterable[key], key, iterable)
|
||||
}
|
||||
var index = findIndex(collection, predicate, fromIndex);
|
||||
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
|
||||
const index = findIndex(collection, predicate, fromIndex)
|
||||
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined
|
||||
}
|
||||
|
||||
export default find
|
||||
|
||||
Reference in New Issue
Block a user