* 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)
| 12608 | * @returns {Function} Returns the new base function. |
| 12609 | */ |
| 12610 | function createBaseEach(eachFunc, fromRight) { |
| 12611 | return function(collection, iteratee) { |
| 12612 | if (collection == null) { |
| 12613 | return collection; |
| 12614 | } |
| 12615 | if (!isArrayLike(collection)) { |
| 12616 | return eachFunc(collection, iteratee); |
| 12617 | } |
| 12618 | var length = collection.length, |
| 12619 | index = fromRight ? length : -1, |
| 12620 | iterable = Object(collection); |
| 12621 | |
| 12622 | while ((fromRight ? index-- : ++index < length)) { |
| 12623 | if (iteratee(iterable[index], index, iterable) === false) { |
| 12624 | break; |
| 12625 | } |
| 12626 | } |
| 12627 | return collection; |
| 12628 | }; |
| 12629 | } |
| 12630 | |
| 12631 | /** |
| 12632 | * Creates a base function for methods like `_.forIn` and `_.forOwn`. |
no test coverage detected