2 * The base implementation of methods like `_.find` and `_.findKey`, without
3 * support for iteratee shorthands, which iterates over `collection` using
7 * @param {Array|Object} collection The collection to search.
8 * @param {Function} predicate The function invoked per iteration.
9 * @param {Function} eachFunc The function to iterate over `collection`.
10 * @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself.
11 * @returns {*} Returns the found element or its key, else `undefined`.
13 function baseFind(collection, predicate, eachFunc, retKey) {
15 eachFunc(collection, function(value, key, collection) {
16 if (predicate(value, key, collection)) {
17 result = retKey ? key : value;
24 module.exports = baseFind;