Sha256: fb95f766d9bbf0d34fafdbd067b7c177db6a57d8642dab6dc8987a2b0f744b45
Contents?: true
Size: 913 Bytes
Versions: 153
Compression:
Stored size: 913 Bytes
Contents
var getLength = require('./getLength'), isLength = require('./isLength'), toObject = require('./toObject'); /** * 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) { var length = collection ? getLength(collection) : 0; if (!isLength(length)) { return eachFunc(collection, iteratee); } var index = fromRight ? length : -1, iterable = toObject(collection); while ((fromRight ? index-- : ++index < length)) { if (iteratee(iterable[index], index, iterable) === false) { break; } } return collection; }; } module.exports = createBaseEach;
Version data entries
153 entries across 80 versions & 8 rubygems