lib/BitStream.js
function BitStream(ab, rtl, opt_offset, opt_length) {
    // if (!ab || !ab.toString || ab.toString() !== "[object ArrayBuffer]") {
    //     throw "Error! BitArray constructed with an invalid ArrayBuffer object";
    // }

    var offset = opt_offset || 0;
    var length = opt_length || ab.byteLength;
    this.bytes = new Uint8Array(ab, offset, length);
    this.bytePtr = 0; // tracks which byte we are on
    this.bitPtr = 0; // tracks which bit we are on (can have values 0 through 7)
    this.peekBits = rtl ? this.peekBits_rtl : this.peekBits_ltr;
}
function BitStream(ab, rtl, opt_offset, opt_length) {
    // if (!ab || !ab.toString || ab.toString() !== "[object ArrayBuffer]") {
    //     throw "Error! BitArray constructed with an invalid ArrayBuffer object";
    // }

    var offset = opt_offset || 0;
    var length = opt_length || ab.byteLength;
    this.bytes = new Uint8Array(ab, offset, length);
    this.bytePtr = 0; // tracks which byte we are on
    this.bitPtr = 0; // tracks which bit we are on (can have values 0 through 7)
    this.peekBits = rtl ? this.peekBits_rtl : this.peekBits_ltr;
}
function BitStream ( ab , rtl , opt_offset , opt_length ) { // if (!ab || !ab.toString || ab.toString() !== "[object ArrayBuffer]") { //     throw "Error! BitArray constructed with an invalid ArrayBuffer object"; // } var offset = opt_offset || 0 ; var length = opt_length || ab . byteLength ; this . bytes = new Uint8Array ( ab , offset , length ) ; this . bytePtr = 0 ; // tracks which byte we are on this . bitPtr = 0 ; // tracks which bit we are on (can have values 0 through 7) this . peekBits = rtl ? this . peekBits_rtl : this . peekBits_ltr ; }
This bit stream peeks and consumes bits out of a binary stream.

@param {ArrayBuffer} ab An ArrayBuffer object or a Uint8Array.
@param {boolean} rtl Whether the stream reads bits from the byte starting
from bit 7 to 0 (true) or bit 0 to 7 (false).
@param {Number} opt_offset The offset into the ArrayBuffer
@param {Number} opt_length The length of this BitStream
This bit stream peeks and consumes bits out of a binary stream .