1 var getLength = require('./getLength'),
2 isLength = require('./isLength'),
3 toObject = require('./toObject');
6 * Creates a `baseEach` or `baseEachRight` function.
9 * @param {Function} eachFunc The function to iterate over a collection.
10 * @param {boolean} [fromRight] Specify iterating from right to left.
11 * @returns {Function} Returns the new base function.
13 function createBaseEach(eachFunc, fromRight) {
14 return function(collection, iteratee) {
15 var length = collection ? getLength(collection) : 0;
16 if (!isLength(length)) {
17 return eachFunc(collection, iteratee);
19 var index = fromRight ? length : -1,
20 iterable = toObject(collection);
22 while ((fromRight ? index-- : ++index < length)) {
23 if (iteratee(iterable[index], index, iterable) === false) {
31 module.exports = createBaseEach;