The
flush() method is called on a compression stream so that it can compel
zlib to return as much output as achievable at present. This output may be returned at the cost of corrupt compression quality but it can be useful when data is required to be accessible as early as possible.
Syntax:
zlib.flush()
Parameters: This method does not accept any parameters.
Return Value: It returns the data as much as possible at present.
Below examples illustrate the use of
zlib.flush() method in Node.js:
Example 1:
Output:
Program Complete!
Input: Data flush received 13 bytes
Example 2:
Output: So, after the byte size exceeds 16384 bytes then you need to callback flush method else data won't be flushed fully.
Program Complete!
Input: Data flush with callback received 16384 bytes
Input: Data flush with callback received 2616 bytes
Reference: https://nodejs.org/api/zlib.html#zlib_flushing