Sha256: 9e95393e564e13302dadff6a3ff87ca48a9af7c8f9da9ebd75d0219cdb9aaa85

Contents?: true

Size: 1.81 KB

Versions: 53

Compression:

Stored size: 1.81 KB

Contents

'use strict';

var clear             = require('es5-ext/array/#/clear')
  , assign            = require('es5-ext/object/assign')
  , setPrototypeOf    = require('es5-ext/object/set-prototype-of')
  , contains          = require('es5-ext/string/#/contains')
  , d                 = require('d')
  , autoBind          = require('d/auto-bind')
  , Iterator          = require('es6-iterator')
  , toStringTagSymbol = require('es6-symbol').toStringTag

  , defineProperties = Object.defineProperties, keys = Object.keys
  , unBind = Iterator.prototype._unBind
  , PrimitiveSetIterator;

PrimitiveSetIterator = module.exports = function (set, kind) {
	if (!(this instanceof PrimitiveSetIterator)) {
		return new PrimitiveSetIterator(set, kind);
	}
	Iterator.call(this, keys(set.__setData__), set);
	kind = (!kind || !contains.call(kind, 'key+value')) ? 'value' : 'key+value';
	defineProperties(this, {
		__kind__: d('', kind),
		__data__: d('w', set.__setData__)
	});
};
if (setPrototypeOf) setPrototypeOf(PrimitiveSetIterator, Iterator);

PrimitiveSetIterator.prototype = Object.create(Iterator.prototype, assign({
	constructor: d(PrimitiveSetIterator),
	_resolve: d(function (i) {
		var value = this.__data__[this.__list__[i]];
		return (this.__kind__ === 'value') ? value : [value, value];
	}),
	_unBind: d(function () {
		this.__data__ = null;
		unBind.call(this);
	}),
	toString: d(function () { return '[object Set Iterator]'; })
}, autoBind({
	_onAdd: d(function (key) { this.__list__.push(key); }),
	_onDelete: d(function (key) {
		var index = this.__list__.lastIndexOf(key);
		if (index < this.__nextIndex__) return;
		this.__list__.splice(index, 1);
	}),
	_onClear: d(function () {
		clear.call(this.__list__);
		this.__nextIndex__ = 0;
	})
})));
Object.defineProperty(PrimitiveSetIterator.prototype, toStringTagSymbol,
	d('c', 'Set Iterator'));

Version data entries

53 entries across 53 versions & 7 rubygems

Version Path
govuk_publishing_components-17.6.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-17.5.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-17.4.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-17.3.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-17.2.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-17.1.1 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-17.1.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-17.0.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.29.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.28.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.27.1 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.27.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.26.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.25.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.24.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.23.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.22.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.21.0 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.20.1 node_modules/es6-set/lib/primitive-iterator.js
govuk_publishing_components-16.20.0 node_modules/es6-set/lib/primitive-iterator.js