This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/core-js/modules/esnext.map.key-by.js

19 lines
554 B
JavaScript
Raw Normal View History

'use strict';
var $ = require('../internals/export');
var iterate = require('../internals/iterate');
var aFunction = require('../internals/a-function');
// `Map.keyBy` method
// https://github.com/tc39/proposal-collection-methods
$({ target: 'Map', stat: true }, {
keyBy: function keyBy(iterable, keyDerivative) {
var newMap = new this();
aFunction(keyDerivative);
var setter = aFunction(newMap.set);
iterate(iterable, function (element) {
setter.call(newMap, keyDerivative(element), element);
});
return newMap;
}
});