]>
git.proxmox.com Git - mirror_novnc.git/blob - core/inflator.js
1 import { inflateInit
, inflate
, inflateReset
} from "../vendor/pako/lib/zlib/inflate.js";
2 import ZStream
from "../vendor/pako/lib/zlib/zstream.js";
5 inflate: function (data
, flush
, expected
) {
6 this.strm
.input
= data
;
7 this.strm
.avail_in
= this.strm
.input
.length
;
9 this.strm
.next_out
= 0;
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
);
19 this.strm
.avail_out
= this.chunkSize
;
21 inflate(this.strm
, flush
);
23 return new Uint8Array(this.strm
.output
.buffer
, 0, this.strm
.next_out
);
27 inflateReset(this.strm
);
31 export default function Inflate() {
32 this.strm
= new ZStream();
33 this.chunkSize
= 1024 * 10 * 10;
34 this.strm
.output
= new Uint8Array(this.chunkSize
);
37 inflateInit(this.strm
, this.windowBits
);