]> git.proxmox.com Git - mirror_novnc.git/blob - utils/inflator.partial.js
2522d78164fee2e43d3a5a0cde07452cbedbfed5
[mirror_novnc.git] / utils / inflator.partial.js
1 var zlib = require('./lib/zlib/inflate.js');
2 var ZStream = require('./lib/zlib/zstream.js');
3
4 var Inflate = function () {
5 this.strm = new ZStream();
6 this.chunkSize = 1024 * 10 * 10;
7 this.strm.output = new Uint8Array(this.chunkSize);
8 this.windowBits = 5;
9
10 zlib.inflateInit(this.strm, this.windowBits);
11 };
12
13 Inflate.prototype = {
14 inflate: function (data, flush) {
15 this.strm.input = data;
16 this.strm.avail_in = this.strm.input.length;
17 this.strm.next_in = 0;
18 this.strm.next_out = 0;
19
20 this.strm.avail_out = this.chunkSize;
21
22 zlib.inflate(this.strm, flush);
23
24 return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
25 },
26
27 reset: function () {
28 zlib.inflateReset(this.strm);
29 }
30 };
31
32 module.exports = {Inflate: Inflate};