2 * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
3 * without support for callback shorthands and `this` binding, which iterates
4 * over `collection` using the provided `eachFunc`.
7 * @param {Array|Object|string} 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
11 * instead of the element itself.
12 * @returns {*} Returns the found element or its key, else `undefined`.
14 function baseFind(collection, predicate, eachFunc, retKey) {
16 eachFunc(collection, function(value, key, collection) {
17 if (predicate(value, key, collection)) {
18 result = retKey ? key : value;
25 module.exports = baseFind;