a zip code crypto-currency system good for red ONLY

iterator.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. var setPrototypeOf = require('es5-ext/object/set-prototype-of')
  3. , d = require('d')
  4. , Iterator = require('es6-iterator')
  5. , toStringTagSymbol = require('es6-symbol').toStringTag
  6. , kinds = require('./iterator-kinds')
  7. , defineProperties = Object.defineProperties
  8. , unBind = Iterator.prototype._unBind
  9. , MapIterator;
  10. MapIterator = module.exports = function (map, kind) {
  11. if (!(this instanceof MapIterator)) return new MapIterator(map, kind);
  12. Iterator.call(this, map.__mapKeysData__, map);
  13. if (!kind || !kinds[kind]) kind = 'key+value';
  14. defineProperties(this, {
  15. __kind__: d('', kind),
  16. __values__: d('w', map.__mapValuesData__)
  17. });
  18. };
  19. if (setPrototypeOf) setPrototypeOf(MapIterator, Iterator);
  20. MapIterator.prototype = Object.create(Iterator.prototype, {
  21. constructor: d(MapIterator),
  22. _resolve: d(function (i) {
  23. if (this.__kind__ === 'value') return this.__values__[i];
  24. if (this.__kind__ === 'key') return this.__list__[i];
  25. return [this.__list__[i], this.__values__[i]];
  26. }),
  27. _unBind: d(function () {
  28. this.__values__ = null;
  29. unBind.call(this);
  30. }),
  31. toString: d(function () { return '[object Map Iterator]'; })
  32. });
  33. Object.defineProperty(MapIterator.prototype, toStringTagSymbol,
  34. d('c', 'Map Iterator'));