@nathanfaucett/iterator
v0.0.2
Published
iterator for the browser and node.js
Downloads
2
Readme
Iterator
Iterator for the browser and node.js
var Iterator = require("@nathanfaucett/iterator");
var array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
index = 0,
length = array.length,
iterator = new Iterator(function next() {
if (index === length) {
return Iterator.createDone();
} else {
return Iterator.createValue(Iterator.VALUES, index, array[index++]);
}
}),
it = iterator.next();
while (!it.done) {
console.log(it.value);
it = iterator.next();
}