ilib
Version:
iLib is a cross-engine library of internationalization (i18n) classes written in pure JS
1 lines • 721 B
JavaScript
var ElementIterator=function(source,map,keysize){this.elements=[],this.source=source,this.map=map,this.keysize=keysize};ElementIterator.prototype._fillBuffer=function(){for(var str=void 0,i=4;0<i;i--)if((str=this.source.peek(i))&&this.map[str])return this.elements=this.elements.concat(this.map[str]),void this.source.consume(i);str&&(this.elements.push(str.charCodeAt(0)<<this.keysize),this.source.consume(1))},ElementIterator.prototype.hasNext=function(){return this.elements.length<1&&this._fillBuffer(),!!this.elements.length},ElementIterator.prototype.next=function(){this.elements.length<1&&this._fillBuffer();var ret=this.elements[0];return this.elements=this.elements.slice(1),ret},module.exports=ElementIterator;