Skip to content

Commit 44acec5

Browse files
RamirezAlextargos
authored andcommitted
doc: add example for zlib.createGzip()
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>
1 parent 4a78fe5 commit 44acec5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

doc/api/zlib.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ const fs = require('fs');
2020
const inp = fs.createReadStream('input.txt');
2121
const out = fs.createWriteStream('input.txt.gz');
2222

23-
inp.pipe(gzip).pipe(out);
23+
inp.pipe(gzip)
24+
.on('error', () => {
25+
// handle error
26+
})
27+
.pipe(out)
28+
.on('error', () => {
29+
// handle error
30+
});
2431
```
2532

2633
It is also possible to compress or decompress data in a single step:
@@ -679,6 +686,7 @@ added: v0.5.8
679686
* `options` {zlib options}
680687

681688
Creates and returns a new [`Gzip`][] object.
689+
See [example][zlib.createGzip example].
682690

683691
## zlib.createInflate([options])
684692
<!-- YAML
@@ -1046,3 +1054,4 @@ Decompress a chunk of data with [`Unzip`][].
10461054
[RFC 7932]: https://www.rfc-editor.org/rfc/rfc7932.txt
10471055
[pool size]: cli.html#cli_uv_threadpool_size_size
10481056
[zlib documentation]: https://zlib.net/manual.html#Constants
1057+
[zlib.createGzip example]: #zlib_zlib

0 commit comments

Comments
 (0)