MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / createBaseEach

Function createBaseEach

lib/web/jshint.js:4619–4635  ·  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

4617 * @returns {Function} Returns the new base function.
4618 */
4619 function createBaseEach(eachFunc, fromRight) {
4620 return function(collection, iteratee) {
4621 var length = collection ? getLength(collection) : 0;
4622 if (!isLength(length)) {
4623 return eachFunc(collection, iteratee);
4624 }
4625 var index = fromRight ? length : -1,
4626 iterable = toObject(collection);
4627
4628 while ((fromRight ? index-- : ++index < length)) {
4629 if (iteratee(iterable[index], index, iterable) === false) {
4630 break;
4631 }
4632 }
4633 return collection;
4634 };
4635 }
4636
4637 /**
4638 * Creates a base function for `_.forIn` or `_.forInRight`.

Callers 1

runInContextFunction · 0.85

Calls 2

isLengthFunction · 0.85
toObjectFunction · 0.70

Tested by

no test coverage detected