Javascript Huffman compression