source: [view]
var c = String.fromCharCode(value), p = this.p + c, r = 0;
// if already in the dictionary
if(p in this.dict){
this.p = p;
return r;
}
stream.putBits(this.dict[this.p], this.width);
// if we need to increase the code length
if((this.code & (this.code + 1)) == 0){
stream.putBits(this.code++, r = this.width++);
}
// add new string
this.dict[p] = this.code++;
this.p = c;
return r + this.width;