MCPcopy Create free account
hub / github.com/RubyLouvre/anu / createBaseEach

Function createBaseEach

test/babel.js:52526–52545  ·  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

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

Callers 1

babel.jsFile · 0.85

Calls 1

isArrayLikeFunction · 0.70

Tested by

no test coverage detected