CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
_baseReduce.js24 linesDownload Raw Back to lodash
1/**2 * The base implementation of `_.reduce` and `_.reduceRight`, without support3 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.4 *5 * @private6 * @param {Array|Object} collection The collection to iterate over.7 * @param {Function} iteratee The function invoked per iteration.8 * @param {*} accumulator The initial value.9 * @param {boolean} initAccum Specify using the first or last element of10 *  `collection` as the initial value.11 * @param {Function} eachFunc The function to iterate over `collection`.12 * @returns {*} Returns the accumulated value.13 */14function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {15  eachFunc(collection, function(value, index, collection) {16    accumulator = initAccum17      ? (initAccum = false, value)18      : iteratee(accumulator, value, index, collection);19  });20  return accumulator;21}22 23module.exports = baseReduce;24 
basant307/AI_Governance_Project · CoolFace