zlib. zstrmd

Represents a handle for interacting with a deflate stream initiated by defnew().

Example
const zstrmd = defnew(…);

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 if needed (for e.g. file output)
zstrmd.write('', Z_FINISH);
defl = ztrmd.read();

zstrmd.error();
See
  • module:zlib#defnew()

Methods

error() → {string}nullable

Query error information.

Returns a string containing a description of the last occurred error or null if there is no error information.

Returns: string

read() → {string}nullable

Reads a chunk of compressed data from the deflate stream.

Returns the current content of the deflate buffer, fed through

Returns: string
See

read() → {string}nullable

Reads a chunk of decompressed data from the inflate stream.

Returns the current content of the inflate buffer, fed through

Returns: string
See

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 is buffered according to the requested flush mode until read via

Parameters:
NameTypeDescription
srcstring

The string of data to deflate.

flushnumber(optional, nullable, default: Z_FINISH)

The zlib flush mode.

Returns: boolean
See
  • module:zlib.zstrmd#read. If `flush` is `Z_FINISH` (the default) then no more data can be written to the stream. Valid `flush`values are `Z_NO_FLUSH, Z_SYNC_FLUSH, Z_PARTIAL_FLUSH, Z_FULL_FLUSH, Z_FINISH` Returns `true` on success. Returns `null` if an error occurred.