Huffman in javascript