hufftree.js
/**
     * Read the next huffman code from the data source and return the
     * value represented by the code.
     * 
     * F.2.2.3
     * 
     * @param {DataViewReader} reader Data source
     * @param {*} img Struct containing information about the image
     */
Read the next huffman code from the data source and return the
value represented by the code.



@param {DataViewReader} reader Data source
@param {*} img Struct containing information about the image
Read the next huffman code from the data source and return the value represented by the code . @param { DataViewReader } reader Data source @param { * } img Struct containing information about the image
decodeHuffman(reader, img) {
        let bitString = "";     
        let node = this;
        while (true) {
            let bit = reader.nextBit(img);
            node = node.descendNode(bit);
            if (node === undefined) {
                console.error("Error: Couldn't find huffman value for huffman code " + bitString);
                break;
            } else if (node.data != undefined) {
                return node.data;
            }
        }
        return undefined;
    }
decodeHuffman ( reader , img ) { let bitString = "" ; let node = this ; while ( true ) { let bit = reader . nextBit ( img ) ; node = node . descendNode ( bit ) ; if ( node === undefined ) { console . error ( "Error: Couldn't find huffman value for huffman code " + bitString ) ; break ; } else if ( node . data != undefined ) { return node . data ; } } return undefined ; }
Read the next huffman code from the data source and return the
 value represented by the code.
Read the next huffman code from the data source and return the value represented by the code .
// For debugging // bitString += bit; // Found a value, so we're done! // console.log("Found value " + node.data + " for huffman code " + bitString);