Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function deflater (emit) {
const stream = new ZStream()
let status = deflateInit2(stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, WINDOW_BITS, 8, Z_DEFAULT_STRATEGY)
if (status !== Z_OK) {
throw new Error('Problem initializing deflate stream: ' + messages[status])
}
return function (data) {
if (data === undefined) return emit()
// Attach the input data
stream.input = data
stream.next_in = 0
stream.avail_in = stream.input.length
let status
let output
let start
function inflater (emit) {
let stream = new ZStream()
const status = inflateInit2(stream, WINDOW_BITS)
if (status !== Z_OK) {
throw new Error('Problem initializing inflate stream: ' + messages[status])
}
return function (data) {
if (data === undefined) return emit()
let start
stream.input = data
stream.next_in = 0
stream.avail_in = stream.input.length
let status, output
let ret = true