* 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)
| 52524 | * @returns {Function} Returns the new base function. |
| 52525 | */ |
| 52526 | function createBaseEach(eachFunc, fromRight) { |
| 52527 | return function (collection, iteratee) { |
| 52528 | if (collection == null) { |
| 52529 | return collection; |
| 52530 | } |
| 52531 | if (!isArrayLike(collection)) { |
| 52532 | return eachFunc(collection, iteratee); |
| 52533 | } |
| 52534 | var length = collection.length, |
| 52535 | index = fromRight ? length : -1, |
| 52536 | iterable = Object(collection); |
| 52537 | |
| 52538 | while (fromRight ? index-- : ++index < length) { |
| 52539 | if (iteratee(iterable[index], index, iterable) === false) { |
| 52540 | break; |
| 52541 | } |
| 52542 | } |
| 52543 | return collection; |
| 52544 | }; |
| 52545 | } |
| 52546 | |
| 52547 | module.exports = createBaseEach; |
| 52548 |