source: trip-planner-front/node_modules/core-js/modules/esnext.map.group-by.js@ b738035

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

initial commit

  • Property mode set to 100644
File size: 755 bytes
Line 
1'use strict';
2var $ = require('../internals/export');
3var iterate = require('../internals/iterate');
4var aFunction = require('../internals/a-function');
5
6// `Map.groupBy` method
7// https://github.com/tc39/proposal-collection-methods
8$({ target: 'Map', stat: true }, {
9 groupBy: function groupBy(iterable, keyDerivative) {
10 var newMap = new this();
11 aFunction(keyDerivative);
12 var has = aFunction(newMap.has);
13 var get = aFunction(newMap.get);
14 var set = aFunction(newMap.set);
15 iterate(iterable, function (element) {
16 var derivedKey = keyDerivative(element);
17 if (!has.call(newMap, derivedKey)) set.call(newMap, derivedKey, [element]);
18 else get.call(newMap, derivedKey).push(element);
19 });
20 return newMap;
21 }
22});
Note: See TracBrowser for help on using the repository browser.