UNPKG

logoots-structs

Version:

Provides several data structures to represent a text using a ropes-like structure and manipulating it

29 lines (24 loc) 488 B
var Iterator = function (it, more) { this.it = it || null; this.more = more || 0; this.nexte = 'a'; this.loadNext(); }; Iterator.prototype.loadNext = function () { if(this.it.hasNext()) { this.nexte = this.it.next(); } else { this.nexte = this.more; this.more = null; } }; Iterator.prototype.hasNext = function () { return this.nexte!=null; }; Iterator.prototype.next = function () { var ret = this.nexte; this.loadNext(); return ret; }; module.exports = Iterator;