mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +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'
|
* // => object for 'barney'
|
||||||
*/
|
*/
|
||||||
function find(collection, predicate, fromIndex) {
|
function find(collection, predicate, fromIndex) {
|
||||||
var iterable = Object(collection);
|
const iterable = Object(collection)
|
||||||
if (!isArrayLike(collection)) {
|
if (!isArrayLike(collection)) {
|
||||||
collection = keys(collection);
|
collection = keys(collection)
|
||||||
predicate = function(key) { return iteratee(iterable[key], key, iterable); };
|
predicate = (key) => iteratee(iterable[key], key, iterable)
|
||||||
}
|
}
|
||||||
var index = findIndex(collection, predicate, fromIndex);
|
const index = findIndex(collection, predicate, fromIndex)
|
||||||
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
|
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
export default find
|
export default find
|
||||||
|
|||||||
Reference in New Issue
Block a user