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