main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
801 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var bind = require('../internals/function-bind-context');
|
---|
4 | var aMap = require('../internals/a-map');
|
---|
5 | var MapHelpers = require('../internals/map-helpers');
|
---|
6 | var iterate = require('../internals/map-iterate');
|
---|
7 |
|
---|
8 | var Map = MapHelpers.Map;
|
---|
9 | var set = MapHelpers.set;
|
---|
10 |
|
---|
11 | // `Map.prototype.mapKeys` method
|
---|
12 | // https://github.com/tc39/proposal-collection-methods
|
---|
13 | $({ target: 'Map', proto: true, real: true, forced: true }, {
|
---|
14 | mapKeys: function mapKeys(callbackfn /* , thisArg */) {
|
---|
15 | var map = aMap(this);
|
---|
16 | var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
---|
17 | var newMap = new Map();
|
---|
18 | iterate(map, function (value, key) {
|
---|
19 | set(newMap, boundFunction(value, key, map), value);
|
---|
20 | });
|
---|
21 | return newMap;
|
---|
22 | }
|
---|
23 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.