massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / esnext.map.reduce.js
1 'use strict';
2 var $ = require('../internals/export');
3 var global = require('../internals/global');
4 var IS_PURE = require('../internals/is-pure');
5 var anObject = require('../internals/an-object');
6 var aCallable = require('../internals/a-callable');
7 var getMapIterator = require('../internals/get-map-iterator');
8 var iterate = require('../internals/iterate');
9
10 var TypeError = global.TypeError;
11
12 // `Map.prototype.reduce` method
13 // https://github.com/tc39/proposal-collection-methods
14 $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
15   reduce: function reduce(callbackfn /* , initialValue */) {
16     var map = anObject(this);
17     var iterator = getMapIterator(map);
18     var noInitial = arguments.length < 2;
19     var accumulator = noInitial ? undefined : arguments[1];
20     aCallable(callbackfn);
21     iterate(iterator, function (key, value) {
22       if (noInitial) {
23         noInitial = false;
24         accumulator = value;
25       } else {
26         accumulator = callbackfn(accumulator, value, key, map);
27       }
28     }, { AS_ENTRIES: true, IS_ITERATOR: true });
29     if (noInitial) throw TypeError('Reduce of empty map with no initial value');
30     return accumulator;
31   }
32 });