From 44acec53862047b2b1e92d599525fd7b7986f73f Mon Sep 17 00:00:00 2001 From: Alex Ramirez Date: Sat, 8 Jun 2019 08:16:21 -0500 Subject: [PATCH] doc: add example for zlib.createGzip() PR-URL: https://github.com/nodejs/node/pull/28136 Reviewed-By: Sam Roberts Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater Reviewed-By: Masashi Hirano Reviewed-By: James M Snell --- doc/api/zlib.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/api/zlib.md b/doc/api/zlib.md index 98501507084aaa..08149db103bce6 100644 --- a/doc/api/zlib.md +++ b/doc/api/zlib.md @@ -20,7 +20,14 @@ const fs = require('fs'); const inp = fs.createReadStream('input.txt'); const out = fs.createWriteStream('input.txt.gz'); -inp.pipe(gzip).pipe(out); +inp.pipe(gzip) + .on('error', () => { + // handle error + }) + .pipe(out) + .on('error', () => { + // handle error + }); ``` It is also possible to compress or decompress data in a single step: @@ -679,6 +686,7 @@ added: v0.5.8 * `options` {zlib options} Creates and returns a new [`Gzip`][] object. +See [example][zlib.createGzip example]. ## zlib.createInflate([options])