* Creates a `baseEach` or `baseEachRight` function. * * @private * @param {Function} eachFunc The function to iterate over a collection. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {Function} Returns the new base function.
(eachFunc, fromRight)
| 4617 | * @returns {Function} Returns the new base function. |
| 4618 | */ |
| 4619 | function createBaseEach(eachFunc, fromRight) { |
| 4620 | return function(collection, iteratee) { |
| 4621 | var length = collection ? getLength(collection) : 0; |
| 4622 | if (!isLength(length)) { |
| 4623 | return eachFunc(collection, iteratee); |
| 4624 | } |
| 4625 | var index = fromRight ? length : -1, |
| 4626 | iterable = toObject(collection); |
| 4627 | |
| 4628 | while ((fromRight ? index-- : ++index < length)) { |
| 4629 | if (iteratee(iterable[index], index, iterable) === false) { |
| 4630 | break; |
| 4631 | } |
| 4632 | } |
| 4633 | return collection; |
| 4634 | }; |
| 4635 | } |
| 4636 | |
| 4637 | /** |
| 4638 | * Creates a base function for `_.forIn` or `_.forInRight`. |
no test coverage detected