map-iterate.js 572 B

123456789101112131415
  1. var uncurryThis = require('../internals/function-uncurry-this');
  2. var iterateSimple = require('../internals/iterate-simple');
  3. var MapHelpers = require('../internals/map-helpers');
  4. var Map = MapHelpers.Map;
  5. var MapPrototype = MapHelpers.proto;
  6. var forEach = uncurryThis(MapPrototype.forEach);
  7. var entries = uncurryThis(MapPrototype.entries);
  8. var next = entries(new Map()).next;
  9. module.exports = function (map, fn, interruptible) {
  10. return interruptible ? iterateSimple(entries(map), function (entry) {
  11. return fn(entry[1], entry[0]);
  12. }, next) : forEach(map, fn);
  13. };