source: trip-planner-front/node_modules/core-js/modules/esnext.map.reduce.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var IS_PURE = require('../internals/is-pure');
4var anObject = require('../internals/an-object');
5var aFunction = require('../internals/a-function');
6var getMapIterator = require('../internals/get-map-iterator');
7var iterate = require('../internals/iterate');
8
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) {
19 if (noInitial) {
20 noInitial = false;
21 accumulator = value;
22 } else {
23 accumulator = callbackfn(accumulator, value, key, map);
24 }
25 }, { AS_ENTRIES: true, IS_ITERATOR: true });
26 if (noInitial) throw TypeError('Reduce of empty map with no initial value');
27 return accumulator;
28 }
29});
Note: See TracBrowser for help on using the repository browser.