31 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			31 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';
 | 
						|
	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'));
 |