From 0d64e15c82598ca991ad6a8792fc38ab12d38029 Mon Sep 17 00:00:00 2001 From: Tino Lange Date: Tue, 9 Jun 2015 21:07:48 +0200 Subject: [PATCH] - high-level wrapper: add documentation for recently introduced Z_SYNC_FLUSH --- lib/deflate.js | 14 +++++++++----- lib/inflate.js | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/deflate.js b/lib/deflate.js index 625ec67..6768561 100644 --- a/lib/deflate.js +++ b/lib/deflate.js @@ -47,7 +47,9 @@ var Z_DEFLATED = 8; * * Compressed result, generated by default [[Deflate#onData]] * and [[Deflate#onEnd]] handlers. Filled after you push last chunk - * (call [[Deflate#push]] with `Z_FINISH` / `true` param). + * (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you + * push a chunk with explicit flush (call [[Deflate#push]] with + * `Z_SYNC_FLUSH` param). **/ /** @@ -171,8 +173,9 @@ var Deflate = function(options) { * * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with * new compressed chunks. Returns `true` on success. The last data block must have - * mode Z_FINISH (or `true`). That flush internal pending buffers and call - * [[Deflate#onEnd]]. + * mode Z_FINISH (or `true`). That will flush internal pending buffers and call + * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you + * can use mode Z_SYNC_FLUSH, keeping the compression context. * * On fail call [[Deflate#onEnd]] with error code and return false. * @@ -272,8 +275,9 @@ Deflate.prototype.onData = function(chunk) { * - status (Number): deflate status. 0 (Z_OK) on success, * other if not. * - * Called once after you tell deflate that input stream complete - * or error happenned. By default - join collected chunks, + * Called once after you tell deflate that the input stream is + * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH) + * or if an error happened. By default - join collected chunks, * free memory and fill `results` / `err` properties. **/ Deflate.prototype.onEnd = function(status) { diff --git a/lib/inflate.js b/lib/inflate.js index b271035..f754336 100644 --- a/lib/inflate.js +++ b/lib/inflate.js @@ -30,7 +30,9 @@ var toString = Object.prototype.toString; * * Uncompressed result, generated by default [[Inflate#onData]] * and [[Inflate#onEnd]] handlers. Filled after you push last chunk - * (call [[Inflate#push]] with `Z_FINISH` / `true` param). + * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you + * push a chunk with explicit flush (call [[Inflate#push]] with + * `Z_SYNC_FLUSH` param). **/ /** @@ -150,8 +152,9 @@ var Inflate = function(options) { * * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with * new output chunks. Returns `true` on success. The last data block must have - * mode Z_FINISH (or `true`). That flush internal pending buffers and call - * [[Inflate#onEnd]]. + * mode Z_FINISH (or `true`). That will flush internal pending buffers and call + * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you + * can use mode Z_SYNC_FLUSH, keeping the decompression context. * * On fail call [[Inflate#onEnd]] with error code and return false. * @@ -272,8 +275,9 @@ Inflate.prototype.onData = function(chunk) { * - status (Number): inflate status. 0 (Z_OK) on success, * other if not. * - * Called once after you tell inflate that input stream complete - * or error happenned. By default - join collected chunks, + * Called either after you tell inflate that the input stream is + * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH) + * or if an error happened. By default - join collected chunks, * free memory and fill `results` / `err` properties. **/ Inflate.prototype.onEnd = function(status) {