Lines Matching +full:node +full:- +full:version
3 <!--introduced_in=v0.10.0-->
5 > Stability: 2 - Stable
7 <!-- source_link=lib/zlib.js -->
9 The `node:zlib` module provides compression functionality implemented using
15 const zlib = require('node:zlib');
18 Compression and decompression are built around the Node.js [Streams API][].
25 const { createGzip } = require('node:zlib');
26 const { pipeline } = require('node:stream');
30 } = require('node:fs');
45 const { promisify } = require('node:util');
65 const { deflate, unzip } = require('node:zlib');
87 const { promisify } = require('node:util');
100 All `zlib` APIs, except those that are explicitly synchronous, use the Node.js
108 const zlib = require('node:zlib');
127 The `node:zlib` module can be used to implement support for the `gzip`, `deflate`
128 and `br` content-encoding mechanisms defined by
129 [HTTP](https://tools.ietf.org/html/rfc7230#section-4.2).
131 The HTTP [`Accept-Encoding`][] header is used within an HTTP request to identify
132 the compression encodings accepted by the client. The [`Content-Encoding`][]
143 const zlib = require('node:zlib');
144 const http = require('node:http');
145 const fs = require('node:fs');
146 const { pipeline } = require('node:stream');
151 headers: { 'Accept-Encoding': 'br,gzip,deflate' } });
162 switch (response.headers['content-encoding']) {
184 const zlib = require('node:zlib');
185 const http = require('node:http');
186 const fs = require('node:fs');
187 const { pipeline } = require('node:stream');
191 // Store both a compressed and an uncompressed version of the resource.
192 response.setHeader('Vary', 'Accept-Encoding');
193 let acceptEncoding = request.headers['accept-encoding'];
210 // Note: This is not a conformant accept-encoding parser.
211 // See https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
213 response.writeHead(200, { 'Content-Encoding': 'deflate' });
216 response.writeHead(200, { 'Content-Encoding': 'gzip' });
219 response.writeHead(200, { 'Content-Encoding': 'br' });
235 // This is a truncated version of the buffer from the above examples
251 This will not change the behavior in other error-throwing situations, e.g.
259 <!--type=misc-->
261 ### For zlib-based streams
263 From `zlib/zconf.h`, modified for Node.js usage:
267 <!-- eslint-disable semi -->
297 In general, greater memory usage options will mean that Node.js has to make
302 ### For Brotli-based streams
304 There are equivalents to the zlib options for Brotli-based streams, although
310 See [below][Brotli parameters] for more details on Brotli-specific options.
322 const zlib = require('node:zlib');
323 const http = require('node:http');
324 const { pipeline } = require('node:stream');
327 // For the sake of simplicity, the Accept-Encoding checks are omitted.
328 response.writeHead(200, { 'content-encoding': 'gzip' });
359 <!-- YAML
361 -->
363 <!--type=misc-->
368 `require('node:zlib').constants`. In the normal course of operations, it will
373 Previously, the constants were available directly from `require('node:zlib')`,
418 <!-- YAML
420 - v11.7.0
421 - v10.16.0
422 -->
424 There are several options and other constants available for Brotli-based
429 The following values are valid flush operations for Brotli-based streams:
435 * This particular operation may be hard to use in a Node.js context,
438 the Node.js API.
450 * `BROTLI_MODE_TEXT`, adjusted for UTF-8 text
492 <!-- YAML
495 - version:
496 - v14.5.0
497 - v12.19.0
498 pr-url: https://github.com/nodejs/node/pull/33516
500 - version: v9.4.0
501 pr-url: https://github.com/nodejs/node/pull/16042
503 - version: v8.0.0
504 pr-url: https://github.com/nodejs/node/pull/12001
506 - version: v5.11.0
507 pr-url: https://github.com/nodejs/node/pull/6069
509 -->
511 <!--type=misc-->
513 Each zlib-based class takes an `options` object. No options are required.
536 <!-- YAML
539 - version:
540 - v14.5.0
541 - v12.19.0
542 pr-url: https://github.com/nodejs/node/pull/33516
544 -->
546 <!--type=misc-->
548 Each Brotli-based class takes an `options` object. All options are optional.
553 * `params` {Object} Key-value object containing indexed [Brotli parameters][].
572 <!-- YAML
574 - v11.7.0
575 - v10.16.0
576 -->
582 <!-- YAML
584 - v11.7.0
585 - v10.16.0
586 -->
592 <!-- YAML
594 -->
600 <!-- YAML
602 -->
608 <!-- YAML
611 - version: v6.0.0
612 pr-url: https://github.com/nodejs/node/pull/5883
615 - version: v5.9.0
616 pr-url: https://github.com/nodejs/node/pull/5120
618 - version: v5.0.0
619 pr-url: https://github.com/nodejs/node/pull/2595
621 -->
627 <!-- YAML
629 -->
635 <!-- YAML
638 - version: v5.0.0
639 pr-url: https://github.com/nodejs/node/pull/2595
641 -->
647 <!-- YAML
650 - version: v6.8.0
651 pr-url: https://github.com/nodejs/node/pull/8512
653 - version: v5.0.0
654 pr-url: https://github.com/nodejs/node/pull/2595
656 -->
662 <!-- YAML
664 -->
666 Decompress either a Gzip- or Deflate-compressed stream by auto-detecting
671 <!-- YAML
674 - version:
675 - v11.7.0
676 - v10.16.0
677 pr-url: https://github.com/nodejs/node/pull/24939
679 -->
681 Not exported by the `node:zlib` module. It is documented here because it is the
684 This class inherits from [`stream.Transform`][], allowing `node:zlib` objects to
689 <!-- YAML
692 -->
694 > Stability: 0 - Deprecated: Use [`zlib.bytesWritten`][] instead.
700 read by the engine, but is inconsistent with other streams in Node.js that
705 <!-- YAML
707 -->
717 <!-- YAML
719 -->
727 <!-- YAML
729 -->
731 * `kind` **Default:** `zlib.constants.Z_FULL_FLUSH` for zlib-based streams,
732 `zlib.constants.BROTLI_OPERATION_FLUSH` for Brotli-based streams.
745 <!-- YAML
747 -->
753 This function is only available for zlib-based streams, i.e. not Brotli.
760 <!-- YAML
762 -->
769 <!-- YAML
771 -->
773 Provides an object enumerating Zlib-related constants.
777 <!-- YAML
779 - v11.7.0
780 - v10.16.0
781 -->
789 <!-- YAML
791 - v11.7.0
792 - v10.16.0
793 -->
801 <!-- YAML
803 -->
811 <!-- YAML
813 -->
822 so Node.js restored the original behavior of upgrading a value of 8 to 9,
824 that effectively uses an 8-bit window only.
828 <!-- YAML
830 -->
838 <!-- YAML
840 -->
849 <!-- YAML
851 -->
859 <!-- YAML
861 -->
869 <!-- YAML
871 -->
879 <!--type=misc-->
891 <!-- YAML
893 - v11.7.0
894 - v10.16.0
895 -->
903 <!-- YAML
905 - v11.7.0
906 - v10.16.0
907 -->
916 <!-- YAML
918 - v11.7.0
919 - v10.16.0
920 -->
928 <!-- YAML
930 - v11.7.0
931 - v10.16.0
932 -->
941 <!-- YAML
944 - version: v9.4.0
945 pr-url: https://github.com/nodejs/node/pull/16042
947 - version: v8.0.0
948 pr-url: https://github.com/nodejs/node/pull/12223
950 - version: v8.0.0
951 pr-url: https://github.com/nodejs/node/pull/12001
953 -->
961 <!-- YAML
964 - version: v9.4.0
965 pr-url: https://github.com/nodejs/node/pull/16042
967 - version: v8.0.0
968 pr-url: https://github.com/nodejs/node/pull/12223
970 - version: v8.0.0
971 pr-url: https://github.com/nodejs/node/pull/12001
973 -->
982 <!-- YAML
985 - version: v8.0.0
986 pr-url: https://github.com/nodejs/node/pull/12223
988 - version: v8.0.0
989 pr-url: https://github.com/nodejs/node/pull/12001
991 -->
999 <!-- YAML
1002 - version: v9.4.0
1003 pr-url: https://github.com/nodejs/node/pull/16042
1005 - version: v8.0.0
1006 pr-url: https://github.com/nodejs/node/pull/12223
1008 - version: v8.0.0
1009 pr-url: https://github.com/nodejs/node/pull/12001
1011 -->
1020 <!-- YAML
1023 - version: v9.4.0
1024 pr-url: https://github.com/nodejs/node/pull/16042
1026 - version: v8.0.0
1027 pr-url: https://github.com/nodejs/node/pull/12223
1029 - version: v8.0.0
1030 pr-url: https://github.com/nodejs/node/pull/12001
1032 -->
1040 <!-- YAML
1043 - version: v9.4.0
1044 pr-url: https://github.com/nodejs/node/pull/16042
1046 - version: v8.0.0
1047 pr-url: https://github.com/nodejs/node/pull/12223
1049 - version: v8.0.0
1050 pr-url: https://github.com/nodejs/node/pull/12001
1052 -->
1061 <!-- YAML
1064 - version: v9.4.0
1065 pr-url: https://github.com/nodejs/node/pull/16042
1067 - version: v8.0.0
1068 pr-url: https://github.com/nodejs/node/pull/12223
1070 - version: v8.0.0
1071 pr-url: https://github.com/nodejs/node/pull/12001
1073 -->
1081 <!-- YAML
1084 - version: v9.4.0
1085 pr-url: https://github.com/nodejs/node/pull/16042
1087 - version: v8.0.0
1088 pr-url: https://github.com/nodejs/node/pull/12223
1090 - version: v8.0.0
1091 pr-url: https://github.com/nodejs/node/pull/12001
1093 -->
1102 <!-- YAML
1105 - version: v9.4.0
1106 pr-url: https://github.com/nodejs/node/pull/16042
1108 - version: v8.0.0
1109 pr-url: https://github.com/nodejs/node/pull/12223
1111 - version: v8.0.0
1112 pr-url: https://github.com/nodejs/node/pull/12001
1114 -->
1122 <!-- YAML
1125 - version: v9.4.0
1126 pr-url: https://github.com/nodejs/node/pull/16042
1128 - version: v8.0.0
1129 pr-url: https://github.com/nodejs/node/pull/12223
1131 - version: v8.0.0
1132 pr-url: https://github.com/nodejs/node/pull/12001
1134 -->
1143 <!-- YAML
1146 - version: v9.4.0
1147 pr-url: https://github.com/nodejs/node/pull/16042
1149 - version: v8.0.0
1150 pr-url: https://github.com/nodejs/node/pull/12223
1152 - version: v8.0.0
1153 pr-url: https://github.com/nodejs/node/pull/12001
1155 -->
1163 <!-- YAML
1166 - version: v9.4.0
1167 pr-url: https://github.com/nodejs/node/pull/16042
1169 - version: v8.0.0
1170 pr-url: https://github.com/nodejs/node/pull/12223
1172 - version: v8.0.0
1173 pr-url: https://github.com/nodejs/node/pull/12001
1175 -->
1184 <!-- YAML
1187 - version: v9.4.0
1188 pr-url: https://github.com/nodejs/node/pull/16042
1190 - version: v8.0.0
1191 pr-url: https://github.com/nodejs/node/pull/12223
1193 - version: v8.0.0
1194 pr-url: https://github.com/nodejs/node/pull/12001
1196 -->
1204 <!-- YAML
1207 - version: v9.4.0
1208 pr-url: https://github.com/nodejs/node/pull/16042
1210 - version: v8.0.0
1211 pr-url: https://github.com/nodejs/node/pull/12223
1213 - version: v8.0.0
1214 pr-url: https://github.com/nodejs/node/pull/12001
1216 -->
1223 [Brotli parameters]: #brotli-constants
1224 [Memory usage tuning]: #memory-usage-tuning
1225 [RFC 7932]: https://www.rfc-editor.org/rfc/rfc7932.txt
1227 [`.flush()`]: #zlibflushkind-callback
1228 [`Accept-Encoding`]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
1229 [`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/A…
1230 [`BrotliCompress`]: #class-zlibbrotlicompress
1231 [`BrotliDecompress`]: #class-zlibbrotlidecompress
1232 [`Buffer`]: buffer.md#class-buffer
1233 [`Content-Encoding`]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11
1234 [`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Data…
1235 [`DeflateRaw`]: #class-zlibdeflateraw
1236 [`Deflate`]: #class-zlibdeflate
1237 [`Gunzip`]: #class-zlibgunzip
1238 [`Gzip`]: #class-zlibgzip
1239 [`InflateRaw`]: #class-zlibinflateraw
1240 [`Inflate`]: #class-zlibinflate
1241 [`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Ty…
1242 [`Unzip`]: #class-zlibunzip
1245 [`stream.Transform`]: stream.md#class-streamtransform
1247 [convenience methods]: #convenience-methods