Sha256: 8fde6568230f3a01ec34320a3ddb29ba4e9608725bf27c634bdc363ddde2ff08
Contents?: true
Size: 886 Bytes
Versions: 300
Compression:
Stored size: 886 Bytes
Contents
var isArrayLike = require('./isArrayLike'); /** * 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. */ function createBaseEach(eachFunc, fromRight) { return function(collection, iteratee) { if (collection == null) { return collection; } if (!isArrayLike(collection)) { return eachFunc(collection, iteratee); } var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection); while ((fromRight ? index-- : ++index < length)) { if (iteratee(iterable[index], index, iterable) === false) { break; } } return collection; }; } module.exports = createBaseEach;
Version data entries
300 entries across 276 versions & 32 rubygems