zlib.ZlibBase
History
Zlib to ZlibBase.class zlib.ZlibBase extends undefined
Not exported by the node:zlib module. It is documented here because it is the
base class of the compressor/decompressor classes.
This class inherits from stream.Transform, allowing node:zlib objects to
be used in pipes and similar stream operations.
numberThe zlib.bytesWritten property specifies the number of bytes written to
the engine, before the bytes are processed (compressed or decompressed,
as appropriate for the derived class).
zlib.close(callback?): void
FunctionClose the underlying handle.
zlib.flush(kind?, callback): void
kindDefault:zlib.constants.Z_FULL_FLUSHfor zlib-based streams,zlib.constants.BROTLI_OPERATION_FLUSHfor Brotli-based streams, andzlib.constants.ZSTD_e_flushfor Zstd-based streams.callbackFunction
Flush pending data. Don't call this frivolously, premature flushes negatively impact the effectiveness of the compression algorithm.
Calling this only flushes data from the internal zlib state, and does not
perform flushing of any kind on the streams level. Rather, it behaves like a
normal call to .write(), i.e. it will be queued up behind other pending
writes and will only produce output when data is being read from the stream.
zlib.params(level, strategy, callback): void
This function is only available for zlib-based streams, i.e. not Brotli.
Dynamically update the compression level and compression strategy. Only applicable to deflate algorithm.
zlib.reset
History
zlib.reset(): void
For inflate and deflate streams, reset the compressor/decompressor to factory defaults.
For Brotli streams, start a new compression or decompression session while preserving the configured parameters and dictionary.
For Zstd streams, cancel the current frame and start a new session while
preserving the configured parameters and dictionary. If pledgedSrcSize was
configured for a Zstd compressor, it applies again to the next frame.
Resetting a gzip stream after it has emitted output for an incomplete member
causes the stream to error with ERR_ZLIB_INCOMPLETE_FRAME. Resetting at
that point would discard the member state while the bytes already written out
remain at the start of the output stream, leaving it undecodable. Call
.end(), or start over with a new gzip stream, instead.
zlib-wrapped deflate may still reset() after a flush; callers that reuse
the compressor discard the first output. Raw deflate has no wrapper header,
so reset() after a flush still concatenates.
Calling reset() while a write is in progress throws an Error.
Resetting an incomplete Zstd compression frame after it has emitted output
causes the stream to error with ERR_ZLIB_INCOMPLETE_FRAME. Resetting at
that point would discard the frame state while the bytes already written
out remain at the start of the output stream, leaving it undecodable. Call
.end(), or start over with a new stream, instead.