]> git.proxmox.com Git - mirror_novnc.git/blame - core/inflator.js
Add eslint and fix reported issues
[mirror_novnc.git] / core / inflator.js
CommitLineData
fba220c6
SR
1import { inflateInit, inflate, inflateReset } from "../vendor/pako/lib/zlib/inflate.js";
2import ZStream from "../vendor/pako/lib/zlib/zstream.js";
ae510306
SR
3
4Inflate.prototype = {
5 inflate: function (data, flush, expected) {
6 this.strm.input = data;
7 this.strm.avail_in = this.strm.input.length;
8 this.strm.next_in = 0;
9 this.strm.next_out = 0;
10
11 // resize our output buffer if it's too small
12 // (we could just use multiple chunks, but that would cause an extra
13 // allocation each time to flatten the chunks)
14 if (expected > this.chunkSize) {
15 this.chunkSize = expected;
16 this.strm.output = new Uint8Array(this.chunkSize);
17 }
18
19 this.strm.avail_out = this.chunkSize;
20
fba220c6 21 inflate(this.strm, flush);
ae510306
SR
22
23 return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
24 },
25
26 reset: function () {
fba220c6 27 inflateReset(this.strm);
6940936f 28 }
6940936f
SR
29};
30
fba220c6
SR
31export default function Inflate() {
32 this.strm = new ZStream();
33 this.chunkSize = 1024 * 10 * 10;
34 this.strm.output = new Uint8Array(this.chunkSize);
35 this.windowBits = 5;
6940936f 36
fba220c6 37 inflateInit(this.strm, this.windowBits);
8727f598 38}