Sha256: d9b83c83c9af1b26cac9e4a54f9470207d690ad5f4114758001a3aff956e7c08

Contents?: true

Size: 925 Bytes

Versions: 4

Compression:

Stored size: 925 Bytes

Contents

'use strict';
var $ = require('../internals/export');
var aCallable = require('../internals/a-callable');
var aSet = require('../internals/a-set');
var iterate = require('../internals/set-iterate');

var $TypeError = TypeError;

// `Set.prototype.reduce` method
// https://github.com/tc39/proposal-collection-methods
$({ target: 'Set', proto: true, real: true, forced: true }, {
  reduce: function reduce(callbackfn /* , initialValue */) {
    var set = aSet(this);
    var noInitial = arguments.length < 2;
    var accumulator = noInitial ? undefined : arguments[1];
    aCallable(callbackfn);
    iterate(set, function (value) {
      if (noInitial) {
        noInitial = false;
        accumulator = value;
      } else {
        accumulator = callbackfn(accumulator, value, value, set);
      }
    });
    if (noInitial) throw new $TypeError('Reduce of empty set with no initial value');
    return accumulator;
  }
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-0.26.10 packages/webpacker/node_modules/core-js/modules/esnext.set.reduce.js
decidim-0.26.9 packages/webpacker/node_modules/core-js/modules/esnext.set.reduce.js
decidim-0.28.0.rc5 packages/webpacker/node_modules/core-js/modules/esnext.set.reduce.js
decidim-0.28.0.rc4 packages/webpacker/node_modules/core-js/modules/esnext.set.reduce.js