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