(a: number[], max: number)
| 338 | } |
| 339 | |
| 340 | private _inflateLengths(a: number[], max: number): void { |
| 341 | let i: number = 0; |
| 342 | let prev: number = 0; |
| 343 | while (i < max) { |
| 344 | const n: number = this._applyHuffman(this._huffman); |
| 345 | switch (n) { |
| 346 | case 0: |
| 347 | case 1: |
| 348 | case 2: |
| 349 | case 3: |
| 350 | case 4: |
| 351 | case 5: |
| 352 | case 6: |
| 353 | case 7: |
| 354 | case 8: |
| 355 | case 9: |
| 356 | case 10: |
| 357 | case 11: |
| 358 | case 12: |
| 359 | case 13: |
| 360 | case 14: |
| 361 | case 15: |
| 362 | prev = n; |
| 363 | a[i] = n; |
| 364 | i++; |
| 365 | break; |
| 366 | case 16: |
| 367 | const end: number = i + 3 + this._getBits(2); |
| 368 | if (end > max) { |
| 369 | throw new FormatError('Invalid data'); |
| 370 | } |
| 371 | while (i < end) { |
| 372 | a[i] = prev; |
| 373 | i++; |
| 374 | } |
| 375 | break; |
| 376 | case 17: |
| 377 | i += 3 + this._getBits(3); |
| 378 | if (i > max) { |
| 379 | throw new FormatError('Invalid data'); |
| 380 | } |
| 381 | break; |
| 382 | case 18: |
| 383 | i += 11 + this._getBits(7); |
| 384 | if (i > max) { |
| 385 | throw new FormatError('Invalid data'); |
| 386 | } |
| 387 | break; |
| 388 | default: { |
| 389 | throw new FormatError('Invalid data'); |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | private _applyHuffman(h: Huffman): number { |
| 396 | if (h instanceof HuffmanFound) { |
no test coverage detected