MCPcopy
hub / github.com/lodash/lodash / createBaseEach

Function createBaseEach

lodash.js:4961–4980  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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`.

Callers 1

lodash.jsFile · 0.85

Calls 2

isArrayLikeFunction · 0.85
iterateeFunction · 0.70

Tested by

no test coverage detected