Represents a handle for interacting with a deflate stream initiated by deflater().
const zstrmd = deflater(…);
for (let data = ...; data; data = ...) {
zstrmd.write(data, Z_PARTIAL_FLUSH); // write uncompressed data to stream
if (foo)
let defl = zstrmd.read(); // read back compressed stream content
}
// terminate the stream at the end of data input to complete a valid archive
zstrmd.write(last_data, Z_FINISH);
defl = ztrmd.read();
zstrmd.error();
- Source
- See
- module:zlib#deflater()
Methods
error() → {string}nullable
Queries error information.
Returns a string containing a description of the last occurred error or null
if there is no error information.
- Source
read() → {string}nullable
Reads a chunk of compressed data from the deflate stream.
Returns the current content of the deflate buffer, fed through module:zlib.deflate#write.
Returns compressed chunk on success.
Returns null
if an error occurred.
- Source
write(src, flushopt, nullable) → {boolean}nullable
Writes a chunk of data to the deflate stream.
Input data must be a string, it is internally compressed by the zlib deflate()
routine, the end result is buffered according to the requested flush
mode until read via module:zlib.zstrmd#read. Valid flush
values are Z_NO_FLUSH
(the default), Z_SYNC_FLUSH, Z_PARTIAL_FLUSH, Z_FULL_FLUSH, Z_FINISH
. If flush
is Z_FINISH
then no more data can be written to the stream. Refer to the Zlib manual for details on each flush mode.
Returns true
on success.
Returns null
if an error occurred.
Name | Type | Description |
---|---|---|
src | string | The string of data to deflate. |
flush | number | (optional, nullable, default: Z_NO_FLUSH )The zlib flush mode. |
- Source