mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-10 11:20:19 +00:00
19 lines
554 B
JavaScript
19 lines
554 B
JavaScript
'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;
|
|
}
|
|
});
|