@@ -123,7 +123,9 @@ method that is used to compressed the last chunk of input data:
123
123
// This is a truncated version of the buffer from the above examples
124
124
const buffer = Buffer .from (' eJzT0yMA' , ' base64' );
125
125
126
- zlib .unzip (buffer, { finishFlush: zlib .Z_SYNC_FLUSH }, (err , buffer ) => {
126
+ zlib .unzip (buffer,
127
+ {finishFlush: zlib .constants .Z_SYNC_FLUSH },
128
+ (err , buffer ) => {
127
129
if (! err) {
128
130
console .log (buffer .toString ());
129
131
} else {
@@ -221,65 +223,56 @@ added: v0.5.8
221
223
222
224
<!-- type=misc-->
223
225
224
- All of the constants defined in ` zlib.h ` are also defined on ` require('zlib') ` .
225
- In the normal course of operations, it will not be necessary to use these
226
- constants. They are documented so that their presence is not surprising. This
227
- section is taken almost directly from the [ zlib documentation] [ ] . See
228
- < http://zlib.net/manual.html#Constants > for more details.
226
+ All of the constants defined in ` zlib.h ` are also defined on
227
+ ` require('zlib').constants ` . In the normal course of operations, it will not be
228
+ necessary to use these constants. They are documented so that their presence is
229
+ not surprising. This section is taken almost directly from the
230
+ [ zlib documentation] [ ] . See < http://zlib.net/manual.html#Constants > for more
231
+ details.
232
+
233
+ * Note* : Previously, the constants were available directly from
234
+ ` require('zlib') ` , for instance ` zlib.Z_NO_FLUSH ` . Accessing the constants
235
+ directly from the module is currently still possible but should be considered
236
+ deprecated.
229
237
230
238
Allowed flush values.
231
239
232
- * ` zlib.Z_NO_FLUSH `
233
- * ` zlib.Z_PARTIAL_FLUSH `
234
- * ` zlib.Z_SYNC_FLUSH `
235
- * ` zlib.Z_FULL_FLUSH `
236
- * ` zlib.Z_FINISH `
237
- * ` zlib.Z_BLOCK `
238
- * ` zlib.Z_TREES `
240
+ * ` zlib.constants. Z_NO_FLUSH `
241
+ * ` zlib.constants. Z_PARTIAL_FLUSH `
242
+ * ` zlib.constants. Z_SYNC_FLUSH `
243
+ * ` zlib.constants. Z_FULL_FLUSH `
244
+ * ` zlib.constants. Z_FINISH `
245
+ * ` zlib.constants. Z_BLOCK `
246
+ * ` zlib.constants. Z_TREES `
239
247
240
248
Return codes for the compression/decompression functions. Negative
241
249
values are errors, positive values are used for special but normal
242
250
events.
243
251
244
- * ` zlib.Z_OK `
245
- * ` zlib.Z_STREAM_END `
246
- * ` zlib.Z_NEED_DICT `
247
- * ` zlib.Z_ERRNO `
248
- * ` zlib.Z_STREAM_ERROR `
249
- * ` zlib.Z_DATA_ERROR `
250
- * ` zlib.Z_MEM_ERROR `
251
- * ` zlib.Z_BUF_ERROR `
252
- * ` zlib.Z_VERSION_ERROR `
252
+ * ` zlib.constants. Z_OK `
253
+ * ` zlib.constants. Z_STREAM_END `
254
+ * ` zlib.constants. Z_NEED_DICT `
255
+ * ` zlib.constants. Z_ERRNO `
256
+ * ` zlib.constants. Z_STREAM_ERROR `
257
+ * ` zlib.constants. Z_DATA_ERROR `
258
+ * ` zlib.constants. Z_MEM_ERROR `
259
+ * ` zlib.constants. Z_BUF_ERROR `
260
+ * ` zlib.constants. Z_VERSION_ERROR `
253
261
254
262
Compression levels.
255
263
256
- * ` zlib.Z_NO_COMPRESSION `
257
- * ` zlib.Z_BEST_SPEED `
258
- * ` zlib.Z_BEST_COMPRESSION `
259
- * ` zlib.Z_DEFAULT_COMPRESSION `
264
+ * ` zlib.constants. Z_NO_COMPRESSION `
265
+ * ` zlib.constants. Z_BEST_SPEED `
266
+ * ` zlib.constants. Z_BEST_COMPRESSION `
267
+ * ` zlib.constants. Z_DEFAULT_COMPRESSION `
260
268
261
269
Compression strategy.
262
270
263
- * ` zlib.Z_FILTERED `
264
- * ` zlib.Z_HUFFMAN_ONLY `
265
- * ` zlib.Z_RLE `
266
- * ` zlib.Z_FIXED `
267
- * ` zlib.Z_DEFAULT_STRATEGY `
268
-
269
- Possible values of the data_type field.
270
-
271
- * ` zlib.Z_BINARY `
272
- * ` zlib.Z_TEXT `
273
- * ` zlib.Z_ASCII `
274
- * ` zlib.Z_UNKNOWN `
275
-
276
- The deflate compression method (the only one supported in this version).
277
-
278
- * ` zlib.Z_DEFLATED `
279
-
280
- For initializing zalloc, zfree, opaque.
281
-
282
- * ` zlib.Z_NULL `
271
+ * ` zlib.constants.Z_FILTERED `
272
+ * ` zlib.constants.Z_HUFFMAN_ONLY `
273
+ * ` zlib.constants.Z_RLE `
274
+ * ` zlib.constants.Z_FIXED `
275
+ * ` zlib.constants.Z_DEFAULT_STRATEGY `
283
276
284
277
## Class Options
285
278
<!-- YAML
@@ -293,8 +286,8 @@ Each class takes an `options` object. All options are optional.
293
286
Note that some options are only relevant when compressing, and are
294
287
ignored by the decompression classes.
295
288
296
- * ` flush ` (default: ` zlib.Z_NO_FLUSH ` )
297
- * ` finishFlush ` (default: ` zlib.Z_FINISH ` )
289
+ * ` flush ` (default: ` zlib.constants. Z_NO_FLUSH ` )
290
+ * ` finishFlush ` (default: ` zlib.constants. Z_FINISH ` )
298
291
* ` chunkSize ` (default: 16* 1024)
299
292
* ` windowBits `
300
293
* ` level ` (compression only)
@@ -368,7 +361,7 @@ class of the compressor/decompressor classes.
368
361
added: v0.5.8
369
362
-->
370
363
371
- ` kind ` defaults to ` zlib.Z_FULL_FLUSH ` .
364
+ ` kind ` defaults to ` zlib.constants. Z_FULL_FLUSH ` .
372
365
373
366
Flush pending data. Don't call this frivolously, premature flushes negatively
374
367
impact the effectiveness of the compression algorithm.
@@ -391,6 +384,10 @@ Only applicable to deflate algorithm.
391
384
added: v0.7.0
392
385
-->
393
386
387
+ ## zlib.constants
388
+
389
+ Provides an object enumerating Zlib-related [ constants] [ ] .
390
+
394
391
Reset the compressor/decompressor to factory defaults. Only applicable to
395
392
the inflate and deflate algorithms.
396
393
@@ -545,3 +542,4 @@ Decompress a Buffer or string with Unzip.
545
542
[ Unzip ] : #zlib_class_zlib_unzip
546
543
[ `.flush()` ] : #zlib_zlib_flush_kind_callback
547
544
[ Buffer ] : buffer.html
545
+ [ constants ] : #constants_constants
0 commit comments