2 var $ = require('../internals/export');
3 var IS_PURE = require('../internals/is-pure');
4 var anObject = require('../internals/an-object');
5 var aFunction = require('../internals/a-function');
6 var getMapIterator = require('../internals/get-map-iterator');
7 var iterate = require('../internals/iterate');
9 // `Map.prototype.reduce` method
10 // https://github.com/tc39/proposal-collection-methods
11 $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
12 reduce: function reduce(callbackfn /* , initialValue */) {
13 var map = anObject(this);
14 var iterator = getMapIterator(map);
15 var noInitial = arguments.length < 2;
16 var accumulator = noInitial ? undefined : arguments[1];
17 aFunction(callbackfn);
18 iterate(iterator, function (key, value) {
23 accumulator = callbackfn(accumulator, value, key, map);
25 }, undefined, true, true);
26 if (noInitial) throw TypeError('Reduce of empty map with no initial value');