mirror of
https://github.com/JasonYANG170/IOTConnect-Web.git
synced 2024-11-23 12:16:29 +00:00
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
var setPrototypeOf = require("es5-ext/object/set-prototype-of")
|
|
, contains = require("es5-ext/string/#/contains")
|
|
, d = require("d")
|
|
, Iterator = require("es6-iterator")
|
|
, toStringTagSymbol = require("es6-symbol").toStringTag
|
|
, defineProperty = Object.defineProperty
|
|
, SetIterator;
|
|
|
|
SetIterator = module.exports = function (set, kind) {
|
|
if (!(this instanceof SetIterator)) return new SetIterator(set, kind);
|
|
Iterator.call(this, set.__setData__, set);
|
|
if (!kind) kind = "value";
|
|
else if (contains.call(kind, "key+value")) kind = "key+value";
|
|
else kind = "value";
|
|
return defineProperty(this, "__kind__", d("", kind));
|
|
};
|
|
if (setPrototypeOf) setPrototypeOf(SetIterator, Iterator);
|
|
|
|
SetIterator.prototype = Object.create(Iterator.prototype, {
|
|
constructor: d(SetIterator),
|
|
_resolve: d(function (i) {
|
|
if (this.__kind__ === "value") return this.__list__[i];
|
|
return [this.__list__[i], this.__list__[i]];
|
|
}),
|
|
toString: d(function () { return "[object Set Iterator]"; })
|
|
});
|
|
defineProperty(SetIterator.prototype, toStringTagSymbol, d("c", "Set Iterator"));
|