zlib. zstrmi

Represents a handle for interacting with an inflate stream initiated by infnew().

Example
const zstrmi = infnew();

for (let data = ...; data; data = ...) {
	zstrmi.write(data, Z_SYNC_FLUSH);	// write compressed data to stream
	if (foo)
	let defl = zstrmi.read();	// read back decompressed stream content
}

// terminate the stream if needed (for e.g. file output)
zstrmi.write('', Z_FINISH);
defl = ztrmi.read();

zstrmi.error();
See
  • module:zlib#infnew()

Methods

write(src, flushopt, nullable) → {boolean}nullable

Writes a chunk of data to the inflate stream.

Input data must be a string, it is internally decompressed 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_FINISH` Returns `true` on success. Returns `null` if an error occurred.