* 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 functi
(eachFunc, fromRight)
| 15497 | * @returns {Function} Returns the new base function. |
| 15498 | */ |
| 15499 | function createBaseEach(eachFunc, fromRight) { |
| 15500 | return function(collection, iteratee) { |
| 15501 | if (collection == null) { |
| 15502 | return collection; |
| 15503 | } |
| 15504 | if (!isArrayLike(collection)) { |
| 15505 | return eachFunc(collection, iteratee); |
| 15506 | } |
| 15507 | var length = collection.length, |
| 15508 | index = fromRight ? length : -1, |
| 15509 | iterable = Object(collection); |
| 15510 | |
| 15511 | while ((fromRight ? index-- : ++index < length)) { |
| 15512 | if (iteratee(iterable[index], index, iterable) === false) { |
| 15513 | break; |
| 15514 | } |
| 15515 | } |
| 15516 | return collection; |
| 15517 | }; |
| 15518 | } |
| 15519 | |
| 15520 | /** |
| 15521 | * Creates a base function for methods like `_.forIn` and `_.forOwn`. |
no test coverage detected