Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.strm.input = data;
this.strm.avail_in = this.strm.input.length;
this.strm.next_in = 0;
this.strm.next_out = 0;
// resize our output buffer if it's too small
// (we could just use multiple chunks, but that would cause an extra
// allocation each time to flatten the chunks)
if (expected > this.chunkSize) {
this.chunkSize = expected;
this.strm.output = new Uint8Array(this.chunkSize);
}
this.strm.avail_out = this.chunkSize;
zlib.inflate(this.strm, flush);
return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
},
this.strm.input = data;
this.strm.avail_in = this.strm.input.length;
this.strm.next_in = 0;
this.strm.next_out = 0;
// resize our output buffer if it's too small
// (we could just use multiple chunks, but that would cause an extra
// allocation each time to flatten the chunks)
if (expected > this.chunkSize) {
this.chunkSize = expected;
this.strm.output = new Uint8Array(this.chunkSize);
}
this.strm.avail_out = this.chunkSize;
zlib.inflate(this.strm, flush);
return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
},
throw new Error('invalid number of gzip magic number bytes read');
}
// fallthrough
case exports.INFLATE:
case exports.GUNZIP:
case exports.INFLATERAW:
this.err = zlib_inflate.inflate(this.strm, this.flush
// If data was encoded with dictionary
);if (this.err === exports.Z_NEED_DICT && this.dictionary) {
// Load it
this.err = zlib_inflate.inflateSetDictionary(this.strm, this.dictionary);
if (this.err === exports.Z_OK) {
// And try to decode again
this.err = zlib_inflate.inflate(this.strm, this.flush);
} else if (this.err === exports.Z_DATA_ERROR) {
// Both inflateSetDictionary() and inflate() return Z_DATA_ERROR.
// Make it possible for After() to tell a bad dictionary from bad
// input.
this.err = exports.Z_NEED_DICT;
}
}
while (this.strm.avail_in > 0 && this.mode === exports.GUNZIP && this.err === exports.Z_STREAM_END && this.strm.next_in[0] !== 0x00) {
// Bytes remain in input buffer. Perhaps this is another compressed
// member in the same archive, or just trailing garbage.
// Trailing zero bytes are okay, though, since they are frequently
// used for padding.
this.reset();
this.err = zlib_inflate.inflate(this.strm, this.flush);
}
strm.next_in = in_off;
strm.avail_out = out_len;
strm.output = out;
strm.next_out = out_off;
switch (this.mode) {
case exports.DEFLATE:
case exports.GZIP:
case exports.DEFLATERAW:
var status = zlib_deflate.deflate(strm, flush);
break;
case exports.UNZIP:
case exports.INFLATE:
case exports.GUNZIP:
case exports.INFLATERAW:
var status = zlib_inflate.inflate(strm, flush);
break;
default:
throw new Error("Unknown mode " + this.mode);
}
if (status !== exports.Z_STREAM_END && status !== exports.Z_OK) {
this._error(status);
}
this.write_in_progress = false;
return [strm.avail_in, strm.avail_out];
};
strm.next_in = in_off;
strm.avail_out = out_len;
strm.output = out;
strm.next_out = out_off;
switch (this.mode) {
case exports.DEFLATE:
case exports.GZIP:
case exports.DEFLATERAW:
var status = zlib_deflate.deflate(strm, flush);
break;
case exports.UNZIP:
case exports.INFLATE:
case exports.GUNZIP:
case exports.INFLATERAW:
var status = zlib_inflate.inflate(strm, flush);
break;
default:
throw new Error("Unknown mode " + this.mode);
}
if (status !== exports.Z_STREAM_END && status !== exports.Z_OK) {
this._error(status);
}
this.write_in_progress = false;
return [strm.avail_in, strm.avail_out];
};