Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Zlib.prototype._process = function () {
var next_expected_header_byte = null;
// If the avail_out is left at 0, then it means that it ran out
// of room. If there was avail_out left over, then it means
// that all of the input was consumed.
switch (this.mode) {
case exports.DEFLATE:
case exports.GZIP:
case exports.DEFLATERAW:
this.err = zlib_deflate.deflate(this.strm, this.flush);
break;
case exports.UNZIP:
if (this.strm.avail_in > 0) {
next_expected_header_byte = this.strm.next_in;
}
switch (this.gzip_id_bytes_read) {
case 0:
if (next_expected_header_byte === null) {
break;
}
if (this.strm.input[next_expected_header_byte] === GZIP_HEADER_ID1) {
this.gzip_id_bytes_read = 1;
next_expected_header_byte++;
else
out.set = bufferSet;
var strm = this.strm;
strm.avail_in = in_len;
strm.input = input;
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;
else
out.set = bufferSet;
var strm = this.strm;
strm.avail_in = in_len;
strm.input = input;
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;