while(width){ var w = Math.min(width, this.available); var v = (w <= width ? value >>> (width - w) : value) << (this.available - w); this.accumulator |= v & (255 >>> (8 - this.available)); this.available -= w; if(!this.available){ this.buffer.push(this.accumulator); this.accumulator = 0; this.available = 8; } width -= w; }