1 var isArrayLike = require('./isArrayLike');
4 * Creates a `baseEach` or `baseEachRight` function.
7 * @param {Function} eachFunc The function to iterate over a collection.
8 * @param {boolean} [fromRight] Specify iterating from right to left.
9 * @returns {Function} Returns the new base function.
11 function createBaseEach(eachFunc, fromRight) {
12 return function(collection, iteratee) {
13 if (collection == null) {
16 if (!isArrayLike(collection)) {
17 return eachFunc(collection, iteratee);
19 var length = collection.length,
20 index = fromRight ? length : -1,
21 iterable = Object(collection);
23 while ((fromRight ? index-- : ++index < length)) {
24 if (iteratee(iterable[index], index, iterable) === false) {
32 module.exports = createBaseEach;