basant307/AI_Governance_Project
048
1function reduce(map, callback, initialValue) {2 if (initialValue == null && map.size === 0) {3 throw new TypeError('Reduce of empty map with no initial value');4 }5 let accumulator = initialValue;6 for (const [key, value] of map) {7 if (accumulator == null) {8 accumulator = value;9 }10 else {11 accumulator = callback(accumulator, value, key, map);12 }13 }14 return accumulator;15}16 17export { reduce };18 