@nathanfaucett/iterator

0.0.2 • Public • Published

Iterator Build Status

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();
}

Readme

Keywords

Package Sidebar

Install

npm i @nathanfaucett/iterator

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • nathanfaucett