1 | "use strict";
|
2 |
|
3 | var setPrototypeOf = require("es5-ext/object/set-prototype-of")
|
4 | , contains = require("es5-ext/string/#/contains")
|
5 | , d = require("d")
|
6 | , Iterator = require("es6-iterator")
|
7 | , toStringTagSymbol = require("es6-symbol").toStringTag
|
8 | , defineProperty = Object.defineProperty
|
9 | , SetIterator;
|
10 |
|
11 | SetIterator = module.exports = function (set, kind) {
|
12 | if (!(this instanceof SetIterator)) return new SetIterator(set, kind);
|
13 | Iterator.call(this, set.__setData__, set);
|
14 | if (!kind) kind = "value";
|
15 | else if (contains.call(kind, "key+value")) kind = "key+value";
|
16 | else kind = "value";
|
17 | return defineProperty(this, "__kind__", d("", kind));
|
18 | };
|
19 | if (setPrototypeOf) setPrototypeOf(SetIterator, Iterator);
|
20 |
|
21 | SetIterator.prototype = Object.create(Iterator.prototype, {
|
22 | constructor: d(SetIterator),
|
23 | _resolve: d(function (i) {
|
24 | if (this.__kind__ === "value") return this.__list__[i];
|
25 | return [this.__list__[i], this.__list__[i]];
|
26 | }),
|
27 | toString: d(function () { return "[object Set Iterator]"; })
|
28 | });
|
29 | defineProperty(SetIterator.prototype, toStringTagSymbol, d("c", "Set Iterator"));
|