Bitstream Class
Manages the packing/unpacking of values as a set number of bits
Constructor
Bitstream
    
        - 
                    
                        buffer
Parameters:
- 
                    
                        bufferArrayan array of 7-bit integers representing the intial data for this Bitstream 
Item Index
Methods
_advance
    
        - 
                    
                        bits
Advance the head by the specified number of bits and check for overread
Parameters:
- 
                    
                        bitsNumberThe number of bits to advance the index by 
_extend
    
        - 
                    
                        bits
Extend the buffer size by the specified number of bits. Also advances the index
Parameters:
- 
                    
                        bitsNumberThe number of bits to expand the buffer by 
_getBits
    
        - 
                    
                        offset
- 
                    
                        n
Return the value of the first n bits starting at offset
Parameters:
- 
                    
                        offsetNumberThe zero-based bit offset to start at 
- 
                    
                        nNumberThe number of bits to unpack the value from 
Returns:
The unsigned value after unpacking
_serializeObject
    
        - 
                    
                        obj
- 
                    
                        description
Calls all serialize methods in this object's prototype chain with
description as its argument. This allows packing and unpacking classes
which use prototypal inheritance.
Parameters:
- 
                    
                        objNetObjectThe object to serialize 
- 
                    
                        descriptionDescriptionThe description to serialize through 
_setBits
    
        - 
                    
                        offset
- 
                    
                        n
- 
                    
                        value
Set the n bits starting at offset to contain the unsigned integer
value
Parameters:
- 
                    
                        offsetNumberThe zero-based bit offset to start at 
- 
                    
                        nNumberThe number of bits to pack the value in to 
- 
                    
                        valueNumberThe value to pack. Will be cast to an unsigned integer and truncated or padded to n bits 
align
    
        ()
    
    
    
    
    
    
    
    
    
    Move the _index to the first position >= the current index which is the beginning of a cell. Used to burn off padding when processing data from "appendData" since it pads to the nearest multiple of CELLSIZE
appendChars
    
        ()
    
    
    
    
    
    
    
    
    
    Append UTF-8 encoded data from a string to this Bitstream
appendData
    
        ()
    
    
    
    
    
    
    
    
    
    Append data from an ArrayBuffer received over a binary websocket to this Bitstream
bitsLeft
    
        ()
    
    
        
            Number
        
    
    
    
    
    
    
    
    
    Returns:
the number of bits which can be read without causing an overread
empty
    
        ()
    
    
    
    
    
    
    
    
    
    Empty the buffer and reset the index
equals
    
        - 
                    
                        other
See if the contents and byte length of the buffer of this Bitstream
and other are exactly equal
Parameters:
- 
                    
                        otherBitstreamThe bitstream to compare with 
Returns:
true if the bistreams are effectively equal
fromArrayBuffer
    
        ()
    
    
    
    
    
    
    
    
    
    Populate the data in this Bitstream from an ArrayBuffer received over a binary websocket
fromChars
    
        ()
    
    
    
    
    
    
        static
    
    
    
    
    Create a bitstream from a valid UTF-8 string
pack
    
        - 
                    
                        obj
Pack an object with a .serialize() method into this bitstream
Parameters:
- 
                    
                        objNetObjectThe object to serialize 
peekFloat
    
        - 
                    
                        bits
Read a normalized float without consuming any bits
Parameters:
- 
                    
                        bitsNumberThe number of bits to peek at 
peekSInt
    
        - 
                    
                        bits
Read a signed integer without consuming any bits
Parameters:
- 
                    
                        bitsNumberThe number of bits to peek at 
peekUInt
    
        - 
                    
                        bits
Read an unsigned integer without consuming any bits
Parameters:
- 
                    
                        bitsNumberThe number of bits to unpack 
readFloat
    
        - 
                    
                        bits
Read a float value, consuming the specified number of bits
Parameters:
- 
                    
                        bitsNumberThe number of bits to unpack 
readSInt
    
        - 
                    
                        bits
Read a signed integer consuming the specified number of bits
Parameters:
- 
                    
                        bitsNumberThe number of bits to unpack 
readString
    
        ()
    
    
        
            
        
    
    
    
    
    
    
    
    
    Read a zero-terminated string value
Returns:
the String read from the bitstream
readUInt
    
        - 
                    
                        bits
Read an unsigned integer consuming the specified number of bits
Parameters:
- 
                    
                        bitsNumberThe number of bits to unpack 
toArrayBuffer
    
        ()
    
    
        
            
        
    
    
    
    
    
    
    
    
    Convert the data in this Bitstream to a Uint8Array containing an
ArrayBuffer suitable for transmitting this data over a binary websocket
Returns:
A Uint8Array containing the data in this Bitstream
toChars
    
        ()
    
    
    
    
    
    
    
    
    
    Convert the data to a valid UTF-8 string
unpack
    
        - 
                    
                        obj
Unpack an object with a .serialize() method from this bitstream
Parameters:
- 
                    
                        objNetObjectThe object to deserialize to 
writeFloat
    
        - 
                    
                        value
- 
                    
                        bits
Write a normalized float in the range [0.0, 1.0] using the specified
number of bits
Parameters:
- 
                    
                        valueNumberValue to write. 
- 
                    
                        bitsNumberThe number of bits to unpack 
writeSInt
    
        - 
                    
                        value
- 
                    
                        bits
write a signed integer using the specified number of bits
Parameters:
- 
                    
                        valueNumberValue to write. Will be truncated or padded to the specified number of bits 
- 
                    
                        bitsNumberThe number of bits to unpack 
writeString
    
        - 
                    
                        value
Write a zero-terminated string number of bits
Parameters:
- 
                    
                        valueStringValue to write. 
writeUInt
    
        - 
                    
                        value
- 
                    
                        bits
Write an unsigned integer using the specified number of bits
Parameters:
- 
                    
                        valueNumberValue to write. 
- 
                    
                        bitsNumberThe number of bits to unpack 
