* 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)
| 4959 | * @returns {Function} Returns the new base function. |
| 4960 | */ |
| 4961 | function createBaseEach(eachFunc, fromRight) { |
| 4962 | return function(collection, iteratee) { |
| 4963 | if (collection == null) { |
| 4964 | return collection; |
| 4965 | } |
| 4966 | if (!isArrayLike(collection)) { |
| 4967 | return eachFunc(collection, iteratee); |
| 4968 | } |
| 4969 | var length = collection.length, |
| 4970 | index = fromRight ? length : -1, |
| 4971 | iterable = Object(collection); |
| 4972 | |
| 4973 | while ((fromRight ? index-- : ++index < length)) { |
| 4974 | if (iteratee(iterable[index], index, iterable) === false) { |
| 4975 | break; |
| 4976 | } |
| 4977 | } |
| 4978 | return collection; |
| 4979 | }; |
| 4980 | } |
| 4981 | |
| 4982 | /** |
| 4983 | * Creates a base function for methods like `_.forIn` and `_.forOwn`. |
no test coverage detected