(expected)
| 34 | } |
| 35 | |
| 36 | inflate(expected) { |
| 37 | // resize our output buffer if it's too small |
| 38 | // (we could just use multiple chunks, but that would cause an extra |
| 39 | // allocation each time to flatten the chunks) |
| 40 | if (expected > this.chunkSize) { |
| 41 | this.chunkSize = expected; |
| 42 | this.strm.output = new Uint8Array(this.chunkSize); |
| 43 | } |
| 44 | |
| 45 | /* eslint-disable camelcase */ |
| 46 | this.strm.next_out = 0; |
| 47 | this.strm.avail_out = expected; |
| 48 | /* eslint-enable camelcase */ |
| 49 | |
| 50 | let ret = inflate(this.strm, 0); // Flush argument not used. |
| 51 | if (ret < 0) { |
| 52 | throw new Error("zlib inflate failed"); |
| 53 | } |
| 54 | |
| 55 | if (this.strm.next_out != expected) { |
| 56 | throw new Error("Incomplete zlib block"); |
| 57 | } |
| 58 | |
| 59 | return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out); |
| 60 | } |
| 61 | |
| 62 | reset() { |
| 63 | inflateReset(this.strm); |
no outgoing calls
no test coverage detected