Skip to content

Commit 1b192f9

Browse files
vsemozhetbytjasnell
authored andcommitted
doc: fix code examples in zlib.md
* Use test() instead of match() in boolean context. * Add spaces in code example. * Fix typo. PR-URL: #13342 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 291669e commit 1b192f9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/api/zlib.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ http.createServer((request, response) => {
102102

103103
// Note: This is not a conformant accept-encoding parser.
104104
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
105-
if (acceptEncoding.match(/\bdeflate\b/)) {
105+
if (/\bdeflate\b/.test(acceptEncoding)) {
106106
response.writeHead(200, { 'Content-Encoding': 'deflate' });
107107
raw.pipe(zlib.createDeflate()).pipe(response);
108-
} else if (acceptEncoding.match(/\bgzip\b/)) {
108+
} else if (/\bgzip\b/.test(acceptEncoding)) {
109109
response.writeHead(200, { 'Content-Encoding': 'gzip' });
110110
raw.pipe(zlib.createGzip()).pipe(response);
111111
} else {
@@ -119,15 +119,15 @@ By default, the `zlib` methods will throw an error when decompressing
119119
truncated data. However, if it is known that the data is incomplete, or
120120
the desire is to inspect only the beginning of a compressed file, it is
121121
possible to suppress the default error handling by changing the flushing
122-
method that is used to compressed the last chunk of input data:
122+
method that is used to decompress the last chunk of input data:
123123

124124
```js
125125
// This is a truncated version of the buffer from the above examples
126126
const buffer = Buffer.from('eJzT0yMA', 'base64');
127127

128128
zlib.unzip(
129129
buffer,
130-
{finishFlush: zlib.constants.Z_SYNC_FLUSH},
130+
{ finishFlush: zlib.constants.Z_SYNC_FLUSH },
131131
(err, buffer) => {
132132
if (!err) {
133133
console.log(buffer.toString());

0 commit comments

Comments
 (0)