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:
554 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var iterate = require('../internals/iterate');
|
---|
4 | var aFunction = require('../internals/a-function');
|
---|
5 |
|
---|
6 | // `Map.keyBy` method
|
---|
7 | // https://github.com/tc39/proposal-collection-methods
|
---|
8 | $({ target: 'Map', stat: true }, {
|
---|
9 | keyBy: function keyBy(iterable, keyDerivative) {
|
---|
10 | var newMap = new this();
|
---|
11 | aFunction(keyDerivative);
|
---|
12 | var setter = aFunction(newMap.set);
|
---|
13 | iterate(iterable, function (element) {
|
---|
14 | setter.call(newMap, keyDerivative(element), element);
|
---|
15 | });
|
---|
16 | return newMap;
|
---|
17 | }
|
---|
18 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.