How to use the es6-iterator.prototype function in es6-iterator

To help you get started, we’ve selected a few es6-iterator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github medikoo / dbjs / _setup / 3.descriptor-property / iterator.js View on Github external
'use strict';

var remove         = require('es5-ext/array/#/remove')
  , assign         = require('es5-ext/object/assign')
  , setPrototypeOf = require('es5-ext/object/set-prototype-of')
  , d              = require('d')
  , autoBind       = require('d/auto-bind')
  , Iterator       = require('es6-iterator')
  , kinds          = require('es6-map/lib/iterator-kinds')
  , byLastModified = require('../utils/compare-by-last-modified')

  , push = Array.prototype.push, defineProperties = Object.defineProperties
  , unBind = Iterator.prototype._unBind
  , DescriptorIterator;

DescriptorIterator = module.exports = function (map, kind) {
	var sKey, sKeys, data;
	if (!(this instanceof DescriptorIterator)) {
		return new DescriptorIterator(map, kind);
	}
	sKeys = [];
	data = map.__descriptors__;
	for (sKey in data) {
		if (data[sKey]._hasValue_()) sKeys.push(sKey);
	}
	Iterator.call(this, sKeys.sort(byLastModified.bind(data)));
	if (!kind || !kinds[kind]) kind = 'key+value';

	defineProperties(this, {
github medikoo / es6-map / lib / primitive-iterator.js View on Github external
'use strict';

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

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

PrimitiveMapIterator = module.exports = function (map, kind) {
	if (!(this instanceof PrimitiveMapIterator)) {
		return new PrimitiveMapIterator(map, kind);
	}
	Iterator.call(this, keys(map.__mapKeysData__), map);
	if (!kind || !kinds[kind]) kind = 'key+value';
	defineProperties(this, {
		__kind__: d('', kind),
		__keysData__: d('w', map.__mapKeysData__),
		__valuesData__: d('w', map.__mapValuesData__)
	});
};
if (setPrototypeOf) setPrototypeOf(PrimitiveMapIterator, Iterator);
github angelozerr / tern.java / core / ternjs / node_modules / tern-eslint / node_modules / eslint / node_modules / es6-map / lib / iterator.js View on Github external
'use strict';

var setPrototypeOf    = require('es5-ext/object/set-prototype-of')
  , d                 = require('d')
  , Iterator          = require('es6-iterator')
  , toStringTagSymbol = require('es6-symbol').toStringTag
  , kinds             = require('./iterator-kinds')

  , defineProperties = Object.defineProperties
  , unBind = Iterator.prototype._unBind
  , MapIterator;

MapIterator = module.exports = function (map, kind) {
	if (!(this instanceof MapIterator)) return new MapIterator(map, kind);
	Iterator.call(this, map.__mapKeysData__, map);
	if (!kind || !kinds[kind]) kind = 'key+value';
	defineProperties(this, {
		__kind__: d('', kind),
		__values__: d('w', map.__mapValuesData__)
	});
};
if (setPrototypeOf) setPrototypeOf(MapIterator, Iterator);

MapIterator.prototype = Object.create(Iterator.prototype, {
	constructor: d(MapIterator),
	_resolve: d(function (i) {
github medikoo / es6-map / lib / iterator.js View on Github external
, defineProperties = Object.defineProperties
  , unBind = Iterator.prototype._unBind
  , MapIterator;

MapIterator = module.exports = function (map, kind) {
	if (!(this instanceof MapIterator)) return new MapIterator(map, kind);
	Iterator.call(this, map.__mapKeysData__, map);
	if (!kind || !kinds[kind]) kind = 'key+value';
	defineProperties(this, {
		__kind__: d('', kind),
		__values__: d('w', map.__mapValuesData__)
	});
};
if (setPrototypeOf) setPrototypeOf(MapIterator, Iterator);

MapIterator.prototype = Object.create(Iterator.prototype, {
	constructor: d(MapIterator),
	_resolve: d(function (i) {
		if (this.__kind__ === 'value') return this.__values__[i];
		if (this.__kind__ === 'key') return this.__list__[i];
		return [this.__list__[i], this.__values__[i]];
	}),
	_unBind: d(function () {
		this.__values__ = null;
		unBind.call(this);
	}),
	toString: d(function () { return '[object Map Iterator]'; })
});
Object.defineProperty(MapIterator.prototype, toStringTagSymbol,
	d('c', 'Map Iterator'));
github angelozerr / tern.java / core / ternjs / node_modules / tern-eslint / node_modules / eslint / node_modules / es6-map / lib / primitive-iterator.js View on Github external
PrimitiveMapIterator = module.exports = function (map, kind) {
	if (!(this instanceof PrimitiveMapIterator)) {
		return new PrimitiveMapIterator(map, kind);
	}
	Iterator.call(this, keys(map.__mapKeysData__), map);
	if (!kind || !kinds[kind]) kind = 'key+value';
	defineProperties(this, {
		__kind__: d('', kind),
		__keysData__: d('w', map.__mapKeysData__),
		__valuesData__: d('w', map.__mapValuesData__)
	});
};
if (setPrototypeOf) setPrototypeOf(PrimitiveMapIterator, Iterator);

PrimitiveMapIterator.prototype = Object.create(Iterator.prototype, assign({
	constructor: d(PrimitiveMapIterator),
	_resolve: d(function (i) {
		if (this.__kind__ === 'value') return this.__valuesData__[this.__list__[i]];
		if (this.__kind__ === 'key') return this.__keysData__[this.__list__[i]];
		return [this.__keysData__[this.__list__[i]],
			this.__valuesData__[this.__list__[i]]];
	}),
	_unBind: d(function () {
		this.__keysData__ = null;
		this.__valuesData__ = null;
		unBind.call(this);
	}),
	toString: d(function () { return '[object Map Iterator]'; })
}, autoBind({
	_onAdd: d(function (key) { this.__list__.push(key); }),
	_onDelete: d(function (key) {
github medikoo / dbjs / _setup / 2.multiple-item / iterator.js View on Github external
'use strict';

var remove         = require('es5-ext/array/#/remove')
  , 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')
  , byLastModified = require('../utils/compare-by-last-modified')
  , unserialize    = require('../unserialize/key')

  , push = Array.prototype.push
  , defineProperties = Object.defineProperties
  , unBind = Iterator.prototype._unBind
  , MultiplePropertyIterator;

MultiplePropertyIterator = module.exports = function (set, kind) {
	var sKey, sKeys, data;
	if (!(this instanceof MultiplePropertyIterator)) {
		return new MultiplePropertyIterator(set, kind);
	}
	sKeys = [];
	data = set.__setData__;
	for (sKey in data) {
		if ((typeof data[sKey] !== 'number') && !data[sKey]._value_) continue;
		sKeys.push(sKey);
	}
	Iterator.call(this, sKeys.sort(byLastModified.bind(data)));
	kind = (!kind || !contains.call(kind, 'key+value')) ? 'value' : 'key+value';
	defineProperties(this, {
github medikoo / es6-map / lib / iterator.js View on Github external
'use strict';

var setPrototypeOf    = require('es5-ext/object/set-prototype-of')
  , d                 = require('d')
  , Iterator          = require('es6-iterator')
  , toStringTagSymbol = require('es6-symbol').toStringTag
  , kinds             = require('./iterator-kinds')

  , defineProperties = Object.defineProperties
  , unBind = Iterator.prototype._unBind
  , MapIterator;

MapIterator = module.exports = function (map, kind) {
	if (!(this instanceof MapIterator)) return new MapIterator(map, kind);
	Iterator.call(this, map.__mapKeysData__, map);
	if (!kind || !kinds[kind]) kind = 'key+value';
	defineProperties(this, {
		__kind__: d('', kind),
		__values__: d('w', map.__mapValuesData__)
	});
};
if (setPrototypeOf) setPrototypeOf(MapIterator, Iterator);

MapIterator.prototype = Object.create(Iterator.prototype, {
	constructor: d(MapIterator),
	_resolve: d(function (i) {
github medikoo / dbjs / _setup / 1.property / iterator.js View on Github external
'use strict';

var remove         = require('es5-ext/array/#/remove')
  , assign         = require('es5-ext/object/assign')
  , create         = require('es5-ext/object/create')
  , setPrototypeOf = require('es5-ext/object/set-prototype-of')
  , d              = require('d')
  , autoBind       = require('d/auto-bind')
  , Iterator       = require('es6-iterator')
  , kinds          = require('es6-map/lib/iterator-kinds')

  , push = Array.prototype.push, hasOwnProperty = Object.hasOwnProperty
  , defineProperties = Object.defineProperties
  , unBind = Iterator.prototype._unBind
  , ObjectIterator, getCompareByLastModified;

getCompareByLastModified = function (object, modifiedMap) {
	return function (a, b) {
		if (hasOwnProperty.call(modifiedMap, a)) a = modifiedMap[a];
		else a = modifiedMap[a] = object._getPropertyLastModified_(a);
		if (hasOwnProperty.call(modifiedMap, b)) b = modifiedMap[b];
		else b = modifiedMap[b] = object._getPropertyLastModified_(b);
		return a - b;
	};
};

ObjectIterator = module.exports = function (map, kind) {
	var sKey, sKeys, data, modifiedMap, desc;
	if (!(this instanceof ObjectIterator)) return new ObjectIterator(map, kind);
	sKeys = [];
github medikoo / es6-set / lib / iterator.js View on Github external
, 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'));
github angelozerr / tern.java / core / ternjs / node_modules / tern-eslint / node_modules / eslint / node_modules / es6-map / lib / iterator.js View on Github external
, defineProperties = Object.defineProperties
  , unBind = Iterator.prototype._unBind
  , MapIterator;

MapIterator = module.exports = function (map, kind) {
	if (!(this instanceof MapIterator)) return new MapIterator(map, kind);
	Iterator.call(this, map.__mapKeysData__, map);
	if (!kind || !kinds[kind]) kind = 'key+value';
	defineProperties(this, {
		__kind__: d('', kind),
		__values__: d('w', map.__mapValuesData__)
	});
};
if (setPrototypeOf) setPrototypeOf(MapIterator, Iterator);

MapIterator.prototype = Object.create(Iterator.prototype, {
	constructor: d(MapIterator),
	_resolve: d(function (i) {
		if (this.__kind__ === 'value') return this.__values__[i];
		if (this.__kind__ === 'key') return this.__list__[i];
		return [this.__list__[i], this.__values__[i]];
	}),
	_unBind: d(function () {
		this.__values__ = null;
		unBind.call(this);
	}),
	toString: d(function () { return '[object Map Iterator]'; })
});
Object.defineProperty(MapIterator.prototype, toStringTagSymbol,
	d('c', 'Map Iterator'));

es6-iterator

Iterator abstraction based on ES6 specification

MIT
Latest version published 7 years ago

Package Health Score

65 / 100
Full package analysis