(h: Huffman)
| 393 | } |
| 394 | |
| 395 | private _applyHuffman(h: Huffman): number { |
| 396 | if (h instanceof HuffmanFound) { |
| 397 | return h.n; |
| 398 | } |
| 399 | if (h instanceof HuffmanNeedBit) { |
| 400 | return this._applyHuffman(this._getBit() ? h.right : h.left); |
| 401 | } |
| 402 | if (h instanceof HuffmanNeedBits) { |
| 403 | return this._applyHuffman(h.table[this._getBits(h.n)]); |
| 404 | } |
| 405 | throw new FormatError('Invalid data'); |
| 406 | } |
| 407 | } |
no test coverage detected