IOTConnect-Web/node_modules/es6-set/lib/iterator.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-05-09 01:49:52 +00:00
"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"));