Skip to content

Commit

Permalink
doc: add example for zlib.createGzip()
Browse files Browse the repository at this point in the history
PR-URL: #28136
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
RamirezAlex authored and targos committed Jul 20, 2019
1 parent 4a78fe5 commit 44acec5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion doc/api/zlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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])
<!-- YAML
Expand Down Expand Up @@ -1046,3 +1054,4 @@ Decompress a chunk of data with [`Unzip`][].
[RFC 7932]: https://www.rfc-editor.org/rfc/rfc7932.txt
[pool size]: cli.html#cli_uv_threadpool_size_size
[zlib documentation]: https://zlib.net/manual.html#Constants
[zlib.createGzip example]: #zlib_zlib

0 comments on commit 44acec5

Please sign in to comment.