4 examples of 'mapiterator' in JavaScript

Every line of 'mapiterator' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
32var MapIterator = function MapIterator(map, kind) {
33 var _index = 0;
34
35 return Object.create({}, {
36 next: {
37 value: function() {
38 // check if index is within bounds
39 if (_index < map.items().length) {
40 switch(kind) {
41 case 'keys': return map.keys()[_index++];
42 case 'values': return map.values()[_index++];
43 case 'keys+values': return [].slice.call(map.items()[_index++]);
44 default: throw new TypeError('Invalid iterator type');
45 }
46 }
47 // TODO: make sure I'm interpreting the spec correctly here
48 throw new Error('Stop Iteration');
49 }
50 },
51 iterator: {
52 value: function() {
53 return this;
54 }
55 },
56 toString: {
57 value: function() {
58 return '[object Map Iterator]';
59 }
60 }
61 });
62};
Important

Use secure code every time

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

1074public iterator():JIterator<K> { return new NavigableHashMapKeySetJIterator(this.impl); }
44function MapIterator(keys, valueGetter) {
45 this._keys = keys;
46 this._valueGetter = valueGetter;
47 this._length = this._keys.length;
48 this._index = -1;
49 this._done = false;
50}
38public reverse(): MapReverseIterator<Key, T, Source>
39{
40 return new MapReverseIterator(this);
41}

Related snippets