Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

esnext.map.map-keys.js 801B

1234567891011121314151617181920212223
  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. var Map = MapHelpers.Map;
  8. var set = MapHelpers.set;
  9. // `Map.prototype.mapKeys` method
  10. // https://github.com/tc39/proposal-collection-methods
  11. $({ target: 'Map', proto: true, real: true, forced: true }, {
  12. mapKeys: function mapKeys(callbackfn /* , thisArg */) {
  13. var map = aMap(this);
  14. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  15. var newMap = new Map();
  16. iterate(map, function (value, key) {
  17. set(newMap, boundFunction(value, key, map), value);
  18. });
  19. return newMap;
  20. }
  21. });