(txt)
| 1349 | return array.slice(0).reverse() // duplicate and reverse to duplicate the array |
| 1350 | } |
| 1351 | bin2str(txt) { |
| 1352 | return txt.replace(/\s*[01]{8}\s*/g, function(bin) { |
| 1353 | return String.fromCharCode(parseInt(bin, 2)) |
| 1354 | }) |
| 1355 | } |
| 1356 | huffmanEncode(str) { |
| 1357 | const tree = createTree(str); |
| 1358 | const codebook = createCodebook(tree); |