1
0
Fork 0
mirror of https://github.com/codedread/bitjs synced 2025-10-03 17:49:16 +02:00

Implement crc32 calculation for issue #29

This commit is contained in:
Jeff Schiller 2021-12-16 15:09:20 -05:00
parent c0afe7637e
commit 596a859bdc
2 changed files with 46 additions and 9 deletions

View file

@ -220,7 +220,8 @@ class ZipLocalFile {
/**
* Returns a table of Huffman codes. Each entry's key is its code and its value is a JavaScript
* object containing {length: 6, symbol: X}.
* @param {number[]} bitLengths
* @param {number[]} bitLengths An array representing the bit lengths of the codes, in order.
* See section 3.2.2 of https://datatracker.ietf.org/doc/html/rfc1951.
* @returns {Map<number, SymbolLengthPair>}
*/
function getHuffmanCodes(bitLengths) {
@ -267,7 +268,7 @@ function getHuffmanCodes(bitLengths) {
for (let n = 0; n < numLengths; ++n) {
const len = bitLengths[n];
if (len != 0) {
table.set(next_code[len], { length: len, symbol: n }); //, bitstring: binaryValueToString(next_code[len],len) };
table.set(next_code[len], { length: len, symbol: n });
next_code[len]++;
}
}