{ "type": "module", "source": "doc/api/zlib.md", "modules": [ { "textRaw": "Zlib", "name": "zlib", "introduced_in": "v0.10.0", "type": "module", "stability": 2, "stabilityText": "Stable", "desc": "
The node:zlib module provides compression functionality implemented using\nGzip, Deflate/Inflate, Brotli, and Zstd.
\n
To access it:
\n
import zlib from 'node:zlib';\n\n
const zlib = require('node:zlib');\n\n
Compression and decompression are built around the Node.js Streams API.
\n
Compressing or decompressing a stream (such as a file) can be accomplished by\npiping the source stream through a zlib Transform stream into a destination\nstream:
\n
import {\n createReadStream,\n createWriteStream,\n} from 'node:fs';\nimport process from 'node:process';\nimport { createGzip } from 'node:zlib';\nimport { pipeline } from 'node:stream';\n\nconst gzip = createGzip();\nconst source = createReadStream('input.txt');\nconst destination = createWriteStream('input.txt.gz');\n\npipeline(source, gzip, destination, (err) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n});\n\n
const {\n createReadStream,\n createWriteStream,\n} = require('node:fs');\nconst { createGzip } = require('node:zlib');\nconst { pipeline } = require('node:stream');\n\nconst gzip = createGzip();\nconst source = createReadStream('input.txt');\nconst destination = createWriteStream('input.txt.gz');\n\npipeline(source, gzip, destination, (err) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n});\n\n
Or, using the promise pipeline API:
\n
import {\n createReadStream,\n createWriteStream,\n} from 'node:fs';\nimport { createGzip } from 'node:zlib';\nimport { pipeline } from 'node:stream/promises';\n\nasync function do_gzip(input, output) {\n const gzip = createGzip();\n const source = createReadStream(input);\n const destination = createWriteStream(output);\n await pipeline(source, gzip, destination);\n}\n\nawait do_gzip('input.txt', 'input.txt.gz');\n\n
const {\n createReadStream,\n createWriteStream,\n} = require('node:fs');\nconst { createGzip } = require('node:zlib');\nconst { pipeline } = require('node:stream/promises');\n\nasync function do_gzip(input, output) {\n const gzip = createGzip();\n const source = createReadStream(input);\n const destination = createWriteStream(output);\n await pipeline(source, gzip, destination);\n}\n\ndo_gzip('input.txt', 'input.txt.gz')\n .catch((err) => {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n });\n\n
It is also possible to compress or decompress data in a single step:
\n
import process from 'node:process';\nimport { Buffer } from 'node:buffer';\nimport { deflate, unzip } from 'node:zlib';\n\nconst input = '.................................';\ndeflate(input, (err, buffer) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n console.log(buffer.toString('base64'));\n});\n\nconst buffer = Buffer.from('eJzT0yMAAGTvBe8=', 'base64');\nunzip(buffer, (err, buffer) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n console.log(buffer.toString());\n});\n\n// Or, Promisified\n\nimport { promisify } from 'node:util';\nconst do_unzip = promisify(unzip);\n\nconst unzippedBuffer = await do_unzip(buffer);\nconsole.log(unzippedBuffer.toString());\n\n
const { deflate, unzip } = require('node:zlib');\n\nconst input = '.................................';\ndeflate(input, (err, buffer) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n console.log(buffer.toString('base64'));\n});\n\nconst buffer = Buffer.from('eJzT0yMAAGTvBe8=', 'base64');\nunzip(buffer, (err, buffer) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n console.log(buffer.toString());\n});\n\n// Or, Promisified\n\nconst { promisify } = require('node:util');\nconst do_unzip = promisify(unzip);\n\ndo_unzip(buffer)\n .then((buf) => console.log(buf.toString()))\n .catch((err) => {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n });\n", "modules": [ { "textRaw": "Threadpool usage and performance considerations", "name": "threadpool_usage_and_performance_considerations", "type": "module", "desc": "
All zlib APIs, except those that are explicitly synchronous, use the Node.js\ninternal threadpool. This can lead to surprising effects and performance\nlimitations in some applications.
\n
Creating and using a large number of zlib objects simultaneously can cause\nsignificant memory fragmentation.
\n
import zlib from 'node:zlib';\nimport { Buffer } from 'node:buffer';\n\nconst payload = Buffer.from('This is some data');\n\n// WARNING: DO NOT DO THIS!\nfor (let i = 0; i < 30000; ++i) {\n zlib.deflate(payload, (err, buffer) => {});\n}\n\n
const zlib = require('node:zlib');\n\nconst payload = Buffer.from('This is some data');\n\n// WARNING: DO NOT DO THIS!\nfor (let i = 0; i < 30000; ++i) {\n zlib.deflate(payload, (err, buffer) => {});\n}\n\n
In the preceding example, 30,000 deflate instances are created concurrently.\nBecause of how some operating systems handle memory allocation and\ndeallocation, this may lead to significant memory fragmentation.
\n
It is strongly recommended that the results of compression\noperations be cached to avoid duplication of effort.
", "displayName": "Threadpool usage and performance considerations" }, { "textRaw": "Compressing HTTP requests and responses", "name": "compressing_http_requests_and_responses", "type": "module", "desc": "
The node:zlib module can be used to implement support for the gzip, deflate,\nbr, and zstd content-encoding mechanisms defined by\nHTTP.
\n
The HTTP Accept-Encoding header is used within an HTTP request to identify\nthe compression encodings accepted by the client. The Content-Encoding\nheader is used to identify the compression encodings actually applied to a\nmessage.
\n
The examples given below are drastically simplified to show the basic concept.\nUsing zlib encoding can be expensive, and the results ought to be cached.\nSee Memory usage tuning for more information on the speed/memory/compression\ntradeoffs involved in zlib usage.
\n
// Client request example\nimport fs from 'node:fs';\nimport zlib from 'node:zlib';\nimport http from 'node:http';\nimport process from 'node:process';\nimport { pipeline } from 'node:stream';\n\nconst request = http.get({ host: 'example.com',\n path: '/',\n port: 80,\n headers: { 'Accept-Encoding': 'br,gzip,deflate,zstd' } });\nrequest.on('response', (response) => {\n const output = fs.createWriteStream('example.com_index.html');\n\n const onError = (err) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n };\n\n switch (response.headers['content-encoding']) {\n case 'br':\n pipeline(response, zlib.createBrotliDecompress(), output, onError);\n break;\n // Or, just use zlib.createUnzip() to handle both of the following cases:\n case 'gzip':\n pipeline(response, zlib.createGunzip(), output, onError);\n break;\n case 'deflate':\n pipeline(response, zlib.createInflate(), output, onError);\n break;\n case 'zstd':\n pipeline(response, zlib.createZstdDecompress(), output, onError);\n break;\n default:\n pipeline(response, output, onError);\n break;\n }\n});\n\n
// Client request example\nconst zlib = require('node:zlib');\nconst http = require('node:http');\nconst fs = require('node:fs');\nconst { pipeline } = require('node:stream');\n\nconst request = http.get({ host: 'example.com',\n path: '/',\n port: 80,\n headers: { 'Accept-Encoding': 'br,gzip,deflate,zstd' } });\nrequest.on('response', (response) => {\n const output = fs.createWriteStream('example.com_index.html');\n\n const onError = (err) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n };\n\n switch (response.headers['content-encoding']) {\n case 'br':\n pipeline(response, zlib.createBrotliDecompress(), output, onError);\n break;\n // Or, just use zlib.createUnzip() to handle both of the following cases:\n case 'gzip':\n pipeline(response, zlib.createGunzip(), output, onError);\n break;\n case 'deflate':\n pipeline(response, zlib.createInflate(), output, onError);\n break;\n case 'zstd':\n pipeline(response, zlib.createZstdDecompress(), output, onError);\n break;\n default:\n pipeline(response, output, onError);\n break;\n }\n});\n\n
// server example\n// Running a gzip operation on every request is quite expensive.\n// It would be much more efficient to cache the compressed buffer.\nimport zlib from 'node:zlib';\nimport http from 'node:http';\nimport fs from 'node:fs';\nimport { pipeline } from 'node:stream';\n\nhttp.createServer((request, response) => {\n const raw = fs.createReadStream('index.html');\n // Store both a compressed and an uncompressed version of the resource.\n response.setHeader('Vary', 'Accept-Encoding');\n const acceptEncoding = request.headers['accept-encoding'] || '';\n\n const onError = (err) => {\n if (err) {\n // If an error occurs, there's not much we can do because\n // the server has already sent the 200 response code and\n // some amount of data has already been sent to the client.\n // The best we can do is terminate the response immediately\n // and log the error.\n response.end();\n console.error('An error occurred:', err);\n }\n };\n\n // Note: This is not a conformant accept-encoding parser.\n // See https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3\n if (/\\bdeflate\\b/.test(acceptEncoding)) {\n response.writeHead(200, { 'Content-Encoding': 'deflate' });\n pipeline(raw, zlib.createDeflate(), response, onError);\n } else if (/\\bgzip\\b/.test(acceptEncoding)) {\n response.writeHead(200, { 'Content-Encoding': 'gzip' });\n pipeline(raw, zlib.createGzip(), response, onError);\n } else if (/\\bbr\\b/.test(acceptEncoding)) {\n response.writeHead(200, { 'Content-Encoding': 'br' });\n pipeline(raw, zlib.createBrotliCompress(), response, onError);\n } else if (/\\bzstd\\b/.test(acceptEncoding)) {\n response.writeHead(200, { 'Content-Encoding': 'zstd' });\n pipeline(raw, zlib.createZstdCompress(), response, onError);\n } else {\n response.writeHead(200, {});\n pipeline(raw, response, onError);\n }\n}).listen(1337);\n\n
// server example\n// Running a gzip operation on every request is quite expensive.\n// It would be much more efficient to cache the compressed buffer.\nconst zlib = require('node:zlib');\nconst http = require('node:http');\nconst fs = require('node:fs');\nconst { pipeline } = require('node:stream');\n\nhttp.createServer((request, response) => {\n const raw = fs.createReadStream('index.html');\n // Store both a compressed and an uncompressed version of the resource.\n response.setHeader('Vary', 'Accept-Encoding');\n const acceptEncoding = request.headers['accept-encoding'] || '';\n\n const onError = (err) => {\n if (err) {\n // If an error occurs, there's not much we can do because\n // the server has already sent the 200 response code and\n // some amount of data has already been sent to the client.\n // The best we can do is terminate the response immediately\n // and log the error.\n response.end();\n console.error('An error occurred:', err);\n }\n };\n\n // Note: This is not a conformant accept-encoding parser.\n // See https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3\n if (/\\bdeflate\\b/.test(acceptEncoding)) {\n response.writeHead(200, { 'Content-Encoding': 'deflate' });\n pipeline(raw, zlib.createDeflate(), response, onError);\n } else if (/\\bgzip\\b/.test(acceptEncoding)) {\n response.writeHead(200, { 'Content-Encoding': 'gzip' });\n pipeline(raw, zlib.createGzip(), response, onError);\n } else if (/\\bbr\\b/.test(acceptEncoding)) {\n response.writeHead(200, { 'Content-Encoding': 'br' });\n pipeline(raw, zlib.createBrotliCompress(), response, onError);\n } else if (/\\bzstd\\b/.test(acceptEncoding)) {\n response.writeHead(200, { 'Content-Encoding': 'zstd' });\n pipeline(raw, zlib.createZstdCompress(), response, onError);\n } else {\n response.writeHead(200, {});\n pipeline(raw, response, onError);\n }\n}).listen(1337);\n\n
By default, the zlib methods will throw an error when decompressing\ntruncated data. However, if it is known that the data is incomplete, or\nthe desire is to inspect only the beginning of a compressed file, it is\npossible to suppress the default error handling by changing the flushing\nmethod that is used to decompress the last chunk of input data:
\n
// This is a truncated version of the buffer from the above examples\nconst buffer = Buffer.from('eJzT0yMA', 'base64');\n\nzlib.unzip(\n buffer,\n // For Brotli, the equivalent is zlib.constants.BROTLI_OPERATION_FLUSH.\n // For Zstd, the equivalent is zlib.constants.ZSTD_e_flush.\n { finishFlush: zlib.constants.Z_SYNC_FLUSH },\n (err, buffer) => {\n if (err) {\n console.error('An error occurred:', err);\n process.exitCode = 1;\n }\n console.log(buffer.toString());\n });\n\n
This will not change the behavior in other error-throwing situations, e.g.\nwhen the input data has an invalid format. Using this method, it will not be\npossible to determine whether the input ended prematurely or lacks the\nintegrity checks, making it necessary to manually check that the\ndecompressed result is valid.
", "displayName": "Compressing HTTP requests and responses" }, { "textRaw": "Flushing", "name": "flushing", "type": "module", "desc": "
Calling .flush() on a compression stream will make zlib return as much\noutput as currently possible. This may come at the cost of degraded compression\nquality, but can be useful when data needs to be available as soon as possible.
\n
In the following example, flush() is used to write a compressed partial\nHTTP response to the client:
\n
import zlib from 'node:zlib';\nimport http from 'node:http';\nimport { pipeline } from 'node:stream';\n\nhttp.createServer((request, response) => {\n // For the sake of simplicity, the Accept-Encoding checks are omitted.\n response.writeHead(200, { 'content-encoding': 'gzip' });\n const output = zlib.createGzip();\n let i;\n\n pipeline(output, response, (err) => {\n if (err) {\n // If an error occurs, there's not much we can do because\n // the server has already sent the 200 response code and\n // some amount of data has already been sent to the client.\n // The best we can do is terminate the response immediately\n // and log the error.\n clearInterval(i);\n response.end();\n console.error('An error occurred:', err);\n }\n });\n\n i = setInterval(() => {\n output.write(`The current time is ${Date()}\\n`, () => {\n // The data has been passed to zlib, but the compression algorithm may\n // have decided to buffer the data for more efficient compression.\n // Calling .flush() will make the data available as soon as the client\n // is ready to receive it.\n output.flush();\n });\n }, 1000);\n}).listen(1337);\n\n
const zlib = require('node:zlib');\nconst http = require('node:http');\nconst { pipeline } = require('node:stream');\n\nhttp.createServer((request, response) => {\n // For the sake of simplicity, the Accept-Encoding checks are omitted.\n response.writeHead(200, { 'content-encoding': 'gzip' });\n const output = zlib.createGzip();\n let i;\n\n pipeline(output, response, (err) => {\n if (err) {\n // If an error occurs, there's not much we can do because\n // the server has already sent the 200 response code and\n // some amount of data has already been sent to the client.\n // The best we can do is terminate the response immediately\n // and log the error.\n clearInterval(i);\n response.end();\n console.error('An error occurred:', err);\n }\n });\n\n i = setInterval(() => {\n output.write(`The current time is ${Date()}\\n`, () => {\n // The data has been passed to zlib, but the compression algorithm may\n // have decided to buffer the data for more efficient compression.\n // Calling .flush() will make the data available as soon as the client\n // is ready to receive it.\n output.flush();\n });\n }, 1000);\n}).listen(1337);\n", "displayName": "Flushing" }, { "textRaw": "Iterable Compression", "name": "iterable_compression", "type": "module", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "desc": "
The node:zlib/iter module provides compression and decompression transforms\nfor use with the node:stream/iter iterable streams API.
\n
This module is available only when the --experimental-stream-iter CLI flag\nis enabled.
\n
Each algorithm has both an async variant (stateful async generator, for use\nwith pull() and pipeTo()) and a sync variant (stateful sync\ngenerator, for use with pullSync() and pipeToSync()).
\n
The async transforms run compression on the libuv threadpool, overlapping\nI/O with JavaScript execution. The sync transforms run compression directly\non the main thread.
\n
\nNote: The defaults for these transforms are tuned for streaming throughput,\nand differ from the defaults in
\nnode:zlib. In particular, gzip/deflate\ndefault to level 4 (not 6) and memLevel 9 (not 8), and Brotli defaults to\nquality 6 (not 11). These choices match common HTTP server configurations\nand provide significantly faster compression with only a small reduction in\ncompression ratio. All defaults can be overridden via options.
\n
import { from, pull, bytes, text } from 'node:stream/iter';\nimport { compressGzip, decompressGzip } from 'node:zlib/iter';\n\n// Async round-trip\nconst compressed = await bytes(pull(from('hello'), compressGzip()));\nconst original = await text(pull(from(compressed), decompressGzip()));\nconsole.log(original); // 'hello'\n\n
const { from, pull, bytes, text } = require('node:stream/iter');\nconst { compressGzip, decompressGzip } = require('node:zlib/iter');\n\nasync function run() {\n const compressed = await bytes(pull(from('hello'), compressGzip()));\n const original = await text(pull(from(compressed), decompressGzip()));\n console.log(original); // 'hello'\n}\n\nrun().catch(console.error);\n\n
import { fromSync, pullSync, textSync } from 'node:stream/iter';\nimport { compressGzipSync, decompressGzipSync } from 'node:zlib/iter';\n\n// Sync round-trip\nconst compressed = pullSync(fromSync('hello'), compressGzipSync());\nconst original = textSync(pullSync(compressed, decompressGzipSync()));\nconsole.log(original); // 'hello'\n\n
const { fromSync, pullSync, textSync } = require('node:stream/iter');\nconst { compressGzipSync, decompressGzipSync } = require('node:zlib/iter');\n\nconst compressed = pullSync(fromSync('hello'), compressGzipSync());\nconst original = textSync(pullSync(compressed, decompressGzipSync()));\nconsole.log(original); // 'hello'\n", "methods": [ { "textRaw": "`compressBrotli([options])`", "name": "compressBrotli", "type": "method", "signatures": [ { "params": [ { "name": "options", "optional": true } ] } ] }, { "textRaw": "`compressBrotliSync([options])`", "name": "compressBrotliSync", "type": "method", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {Object}", "name": "options", "type": "Object", "options": [ { "textRaw": "`chunkSize` {number} Output buffer size. **Default:** `65536` (64 KB).", "name": "chunkSize", "type": "number", "default": "`65536` (64 KB)", "desc": "Output buffer size." }, { "textRaw": "`params` {Object} Key-value object where keys and values are `zlib.constants` entries. The most important compressor parameters are:", "name": "params", "type": "Object", "desc": "Key-value object where keys and values are `zlib.constants` entries. The most important compressor parameters are:", "options": [ { "textRaw": "`BROTLI_PARAM_MODE` -- `BROTLI_MODE_GENERIC` (default), `BROTLI_MODE_TEXT`, or `BROTLI_MODE_FONT`.", "name": "BROTLI_PARAM_MODE", "desc": "- `BROTLI_MODE_GENERIC` (default), `BROTLI_MODE_TEXT`, or `BROTLI_MODE_FONT`." }, { "textRaw": "`BROTLI_PARAM_QUALITY` -- ranges from `BROTLI_MIN_QUALITY` to `BROTLI_MAX_QUALITY`. **Default:** `6` (not `BROTLI_DEFAULT_QUALITY` which is 11). Quality 6 is appropriate for streaming; quality 11 is intended for offline/build-time compression.", "name": "BROTLI_PARAM_QUALITY", "default": "`6` (not `BROTLI_DEFAULT_QUALITY` which is 11). Quality 6 is appropriate for streaming; quality 11 is intended for offline/build-time compression", "desc": "- ranges from `BROTLI_MIN_QUALITY` to `BROTLI_MAX_QUALITY`." }, { "textRaw": "`BROTLI_PARAM_SIZE_HINT` -- expected input size. **Default:** `0` (unknown).", "name": "BROTLI_PARAM_SIZE_HINT", "default": "`0` (unknown)", "desc": "- expected input size." }, { "textRaw": "`BROTLI_PARAM_LGWIN` -- window size (log2). **Default:** `20` (1 MB). The Brotli library default is 22 (4 MB); the reduced default saves memory without significant compression impact for streaming workloads.", "name": "BROTLI_PARAM_LGWIN", "default": "`20` (1 MB). The Brotli library default is 22 (4 MB); the reduced default saves memory without significant compression impact for streaming workloads", "desc": "- window size (log2)." }, { "textRaw": "`BROTLI_PARAM_LGBLOCK` -- input block size (log2). See the Brotli compressor options in the zlib documentation for the full list.", "name": "BROTLI_PARAM_LGBLOCK", "desc": "- input block size (log2). See the Brotli compressor options in the zlib documentation for the full list." } ] }, { "textRaw": "`dictionary` {Buffer|TypedArray|DataView}", "name": "dictionary", "type": "Buffer|TypedArray|DataView" } ], "optional": true } ], "return": { "textRaw": "Returns: {Object} A stateful transform.", "name": "return", "type": "Object", "desc": "A stateful transform." } } ], "desc": "
Create a Brotli compression transform. Output is compatible with\nzlib.brotliDecompress() and decompressBrotli()/decompressBrotliSync().
" }, { "textRaw": "`compressDeflate([options])`", "name": "compressDeflate", "type": "method", "signatures": [ { "params": [ { "name": "options", "optional": true } ] } ] }, { "textRaw": "`compressDeflateSync([options])`", "name": "compressDeflateSync", "type": "method", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {Object}", "name": "options", "type": "Object", "options": [ { "textRaw": "`chunkSize` {number} Output buffer size. **Default:** `65536` (64 KB).", "name": "chunkSize", "type": "number", "default": "`65536` (64 KB)", "desc": "Output buffer size." }, { "textRaw": "`level` {number} Compression level (`0`-`9`). **Default:** `4`.", "name": "level", "type": "number", "default": "`4`", "desc": "Compression level (`0`-`9`)." }, { "textRaw": "`windowBits` {number} **Default:** `Z_DEFAULT_WINDOWBITS` (15).", "name": "windowBits", "type": "number", "default": "`Z_DEFAULT_WINDOWBITS` (15)" }, { "textRaw": "`memLevel` {number} **Default:** `9`.", "name": "memLevel", "type": "number", "default": "`9`" }, { "textRaw": "`strategy` {number} **Default:** `Z_DEFAULT_STRATEGY`.", "name": "strategy", "type": "number", "default": "`Z_DEFAULT_STRATEGY`" }, { "textRaw": "`dictionary` {Buffer|TypedArray|DataView}", "name": "dictionary", "type": "Buffer|TypedArray|DataView" } ], "optional": true } ], "return": { "textRaw": "Returns: {Object} A stateful transform.", "name": "return", "type": "Object", "desc": "A stateful transform." } } ], "desc": "
Create a deflate compression transform. Output is compatible with\nzlib.inflate() and decompressDeflate()/decompressDeflateSync().
" }, { "textRaw": "`compressGzip([options])`", "name": "compressGzip", "type": "method", "signatures": [ { "params": [ { "name": "options", "optional": true } ] } ] }, { "textRaw": "`compressGzipSync([options])`", "name": "compressGzipSync", "type": "method", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {Object}", "name": "options", "type": "Object", "options": [ { "textRaw": "`chunkSize` {number} Output buffer size. **Default:** `65536` (64 KB).", "name": "chunkSize", "type": "number", "default": "`65536` (64 KB)", "desc": "Output buffer size." }, { "textRaw": "`level` {number} Compression level (`0`-`9`). **Default:** `4`.", "name": "level", "type": "number", "default": "`4`", "desc": "Compression level (`0`-`9`)." }, { "textRaw": "`windowBits` {number} **Default:** `Z_DEFAULT_WINDOWBITS` (15).", "name": "windowBits", "type": "number", "default": "`Z_DEFAULT_WINDOWBITS` (15)" }, { "textRaw": "`memLevel` {number} **Default:** `9`.", "name": "memLevel", "type": "number", "default": "`9`" }, { "textRaw": "`strategy` {number} **Default:** `Z_DEFAULT_STRATEGY`.", "name": "strategy", "type": "number", "default": "`Z_DEFAULT_STRATEGY`" }, { "textRaw": "`dictionary` {Buffer|TypedArray|DataView}", "name": "dictionary", "type": "Buffer|TypedArray|DataView" } ], "optional": true } ], "return": { "textRaw": "Returns: {Object} A stateful transform.", "name": "return", "type": "Object", "desc": "A stateful transform." } } ], "desc": "
Create a gzip compression transform. Output is compatible with zlib.gunzip()\nand decompressGzip()/decompressGzipSync().
" }, { "textRaw": "`compressZstd([options])`", "name": "compressZstd", "type": "method", "signatures": [ { "params": [ { "name": "options", "optional": true } ] } ] }, { "textRaw": "`compressZstdSync([options])`", "name": "compressZstdSync", "type": "method", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {Object}", "name": "options", "type": "Object", "options": [ { "textRaw": "`chunkSize` {number} Output buffer size. **Default:** `65536` (64 KB).", "name": "chunkSize", "type": "number", "default": "`65536` (64 KB)", "desc": "Output buffer size." }, { "textRaw": "`params` {Object} Key-value object where keys and values are `zlib.constants` entries. The most important compressor parameters are:", "name": "params", "type": "Object", "desc": "Key-value object where keys and values are `zlib.constants` entries. The most important compressor parameters are:", "options": [ { "textRaw": "`ZSTD_c_compressionLevel` -- **Default:** `ZSTD_CLEVEL_DEFAULT` (3).", "name": "ZSTD_c_compressionLevel", "default": "`ZSTD_CLEVEL_DEFAULT` (3)", "desc": "-" }, { "textRaw": "`ZSTD_c_checksumFlag` -- generate a checksum. **Default:** `0`.", "name": "ZSTD_c_checksumFlag", "default": "`0`", "desc": "- generate a checksum." }, { "textRaw": "`ZSTD_c_strategy` -- compression strategy. Values include `ZSTD_fast`, `ZSTD_dfast`, `ZSTD_greedy`, `ZSTD_lazy`, `ZSTD_lazy2`, `ZSTD_btlazy2`, `ZSTD_btopt`, `ZSTD_btultra`, `ZSTD_btultra2`. See the Zstd compressor options in the zlib documentation for the full list.", "name": "ZSTD_c_strategy", "desc": "- compression strategy. Values include `ZSTD_fast`, `ZSTD_dfast`, `ZSTD_greedy`, `ZSTD_lazy`, `ZSTD_lazy2`, `ZSTD_btlazy2`, `ZSTD_btopt`, `ZSTD_btultra`, `ZSTD_btultra2`. See the Zstd compressor options in the zlib documentation for the full list." } ] }, { "textRaw": "`pledgedSrcSize` {number} Expected uncompressed size (optional hint).", "name": "pledgedSrcSize", "type": "number", "desc": "Expected uncompressed size (optional hint)." }, { "textRaw": "`dictionary` {Buffer|TypedArray|DataView}", "name": "dictionary", "type": "Buffer|TypedArray|DataView" } ], "optional": true } ], "return": { "textRaw": "Returns: {Object} A stateful transform.", "name": "return", "type": "Object", "desc": "A stateful transform." } } ], "desc": "
Create a Zstandard compression transform. Output is compatible with\nzlib.zstdDecompress() and decompressZstd()/decompressZstdSync().
" }, { "textRaw": "`decompressBrotli([options])`", "name": "decompressBrotli", "type": "method", "signatures": [ { "params": [ { "name": "options", "optional": true } ] } ] }, { "textRaw": "`decompressBrotliSync([options])`", "name": "decompressBrotliSync", "type": "method", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {Object}", "name": "options", "type": "Object", "options": [ { "textRaw": "`chunkSize` {number} Output buffer size. **Default:** `65536` (64 KB).", "name": "chunkSize", "type": "number", "default": "`65536` (64 KB)", "desc": "Output buffer size." }, { "textRaw": "`params` {Object} Key-value object where keys and values are `zlib.constants` entries. Available decompressor parameters:", "name": "params", "type": "Object", "desc": "Key-value object where keys and values are `zlib.constants` entries. Available decompressor parameters:", "options": [ { "textRaw": "`BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION` -- boolean flag affecting internal memory allocation.", "name": "BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION", "desc": "- boolean flag affecting internal memory allocation." }, { "textRaw": "`BROTLI_DECODER_PARAM_LARGE_WINDOW` -- boolean flag enabling \"Large Window Brotli\" mode (not compatible with RFC 7932). See the Brotli decompressor options in the zlib documentation for details.", "name": "BROTLI_DECODER_PARAM_LARGE_WINDOW", "desc": "- boolean flag enabling \"Large Window Brotli\" mode (not compatible with RFC 7932). See the Brotli decompressor options in the zlib documentation for details." } ] }, { "textRaw": "`dictionary` {Buffer|TypedArray|DataView}", "name": "dictionary", "type": "Buffer|TypedArray|DataView" } ], "optional": true } ], "return": { "textRaw": "Returns: {Object} A stateful transform.", "name": "return", "type": "Object", "desc": "A stateful transform." } } ], "desc": "
Create a Brotli decompression transform.
" }, { "textRaw": "`decompressDeflate([options])`", "name": "decompressDeflate", "type": "method", "signatures": [ { "params": [ { "name": "options", "optional": true } ] } ] }, { "textRaw": "`decompressDeflateSync([options])`", "name": "decompressDeflateSync", "type": "method", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {Object}", "name": "options", "type": "Object", "options": [ { "textRaw": "`chunkSize` {number} Output buffer size. **Default:** `65536` (64 KB).", "name": "chunkSize", "type": "number", "default": "`65536` (64 KB)", "desc": "Output buffer size." }, { "textRaw": "`windowBits` {number} **Default:** `Z_DEFAULT_WINDOWBITS` (15).", "name": "windowBits", "type": "number", "default": "`Z_DEFAULT_WINDOWBITS` (15)" }, { "textRaw": "`dictionary` {Buffer|TypedArray|DataView}", "name": "dictionary", "type": "Buffer|TypedArray|DataView" } ], "optional": true } ], "return": { "textRaw": "Returns: {Object} A stateful transform.", "name": "return", "type": "Object", "desc": "A stateful transform." } } ], "desc": "
Create a deflate decompression transform.
" }, { "textRaw": "`decompressGzip([options])`", "name": "decompressGzip", "type": "method", "signatures": [ { "params": [ { "name": "options", "optional": true } ] } ] }, { "textRaw": "`decompressGzipSync([options])`", "name": "decompressGzipSync", "type": "method", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {Object}", "name": "options", "type": "Object", "options": [ { "textRaw": "`chunkSize` {number} Output buffer size. **Default:** `65536` (64 KB).", "name": "chunkSize", "type": "number", "default": "`65536` (64 KB)", "desc": "Output buffer size." }, { "textRaw": "`windowBits` {number} **Default:** `Z_DEFAULT_WINDOWBITS` (15).", "name": "windowBits", "type": "number", "default": "`Z_DEFAULT_WINDOWBITS` (15)" }, { "textRaw": "`dictionary` {Buffer|TypedArray|DataView}", "name": "dictionary", "type": "Buffer|TypedArray|DataView" } ], "optional": true } ], "return": { "textRaw": "Returns: {Object} A stateful transform.", "name": "return", "type": "Object", "desc": "A stateful transform." } } ], "desc": "
Create a gzip decompression transform.
" }, { "textRaw": "`decompressZstd([options])`", "name": "decompressZstd", "type": "method", "signatures": [ { "params": [ { "name": "options", "optional": true } ] } ] }, { "textRaw": "`decompressZstdSync([options])`", "name": "decompressZstdSync", "type": "method", "meta": { "added": [ "v25.9.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {Object}", "name": "options", "type": "Object", "options": [ { "textRaw": "`chunkSize` {number} Output buffer size. **Default:** `65536` (64 KB).", "name": "chunkSize", "type": "number", "default": "`65536` (64 KB)", "desc": "Output buffer size." }, { "textRaw": "`params` {Object} Key-value object where keys and values are `zlib.constants` entries. Available decompressor parameters:", "name": "params", "type": "Object", "desc": "Key-value object where keys and values are `zlib.constants` entries. Available decompressor parameters:", "options": [ { "textRaw": "`ZSTD_d_windowLogMax` -- maximum window size (log2) the decompressor will allocate. Limits memory usage against malicious input. See the Zstd decompressor options in the zlib documentation for details.", "name": "ZSTD_d_windowLogMax", "desc": "- maximum window size (log2) the decompressor will allocate. Limits memory usage against malicious input. See the Zstd decompressor options in the zlib documentation for details." } ] }, { "textRaw": "`dictionary` {Buffer|TypedArray|DataView}", "name": "dictionary", "type": "Buffer|TypedArray|DataView" } ], "optional": true } ], "return": { "textRaw": "Returns: {Object} A stateful transform.", "name": "return", "type": "Object", "desc": "A stateful transform." } } ], "desc": "
Create a Zstandard decompression transform.
" } ], "displayName": "Iterable Compression" } ], "miscs": [ { "textRaw": "Memory usage tuning", "name": "Memory usage tuning", "type": "misc", "miscs": [ { "textRaw": "For zlib-based streams", "name": "for_zlib-based_streams", "type": "misc", "desc": "
From zlib/zconf.h, modified for Node.js usage:
\n
The memory requirements for deflate are (in bytes):
\n
(1 << (windowBits + 2)) + (1 << (memLevel + 9));\n\n
That is: 128K for windowBits = 15 + 128K for memLevel = 8\n(default values) plus a few kilobytes for small objects.
\n
For example, to reduce the default memory requirements from 256K to 128K, the\noptions should be set to:
\n
const options = { windowBits: 14, memLevel: 7 };\n\n
This will, however, generally degrade compression.
\n
The memory requirements for inflate are (in bytes) 1 << windowBits.\nThat is, 32K for windowBits = 15 (default value) plus a few kilobytes\nfor small objects.
\n
This is in addition to a single internal output slab buffer of size\nchunkSize, which defaults to 16K.
\n
The speed of zlib compression is affected most dramatically by the\nlevel setting. A higher level will result in better compression, but\nwill take longer to complete. A lower level will result in less\ncompression, but will be much faster.
\n
In general, greater memory usage options will mean that Node.js has to make\nfewer calls to zlib because it will be able to process more data on\neach write operation. So, this is another factor that affects the\nspeed, at the cost of memory usage.
", "displayName": "For zlib-based streams" }, { "textRaw": "For Brotli-based streams", "name": "for_brotli-based_streams", "type": "misc", "desc": "
There are equivalents to the zlib options for Brotli-based streams, although\nthese options have different ranges than the zlib ones:
\n
level option matches Brotli's BROTLI_PARAM_QUALITY option.windowBits option matches Brotli's BROTLI_PARAM_LGWIN option.\n
See below for more details on Brotli-specific options.
", "displayName": "For Brotli-based streams" }, { "textRaw": "For Zstd-based streams", "name": "for_zstd-based_streams", "type": "misc", "stability": 1, "stabilityText": "Experimental", "desc": "
There are equivalents to the zlib options for Zstd-based streams, although\nthese options have different ranges than the zlib ones:
\n
level option matches Zstd's ZSTD_c_compressionLevel option.windowBits option matches Zstd's ZSTD_c_windowLog option.\n
See below for more details on Zstd-specific options.
", "displayName": "For Zstd-based streams" } ] }, { "textRaw": "Constants", "name": "Constants", "type": "misc", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "miscs": [ { "textRaw": "zlib constants", "name": "zlib_constants", "type": "misc", "desc": "
All of the constants defined in zlib.h are also defined on\nrequire('node:zlib').constants. In the normal course of operations, it will\nnot be necessary to use these constants. They are documented so that their\npresence is not surprising. This section is taken almost directly from the\nzlib documentation.
\n
Previously, the constants were available directly from require('node:zlib'),\nfor instance zlib.Z_NO_FLUSH. Accessing the constants directly from the module\nis currently still possible but is deprecated.
\n
Allowed flush values.
\n
zlib.constants.Z_NO_FLUSHzlib.constants.Z_PARTIAL_FLUSHzlib.constants.Z_SYNC_FLUSHzlib.constants.Z_FULL_FLUSHzlib.constants.Z_FINISHzlib.constants.Z_BLOCK\n
Return codes for the compression/decompression functions. Negative\nvalues are errors, positive values are used for special but normal\nevents.
\n
zlib.constants.Z_OKzlib.constants.Z_STREAM_ENDzlib.constants.Z_NEED_DICTzlib.constants.Z_ERRNOzlib.constants.Z_STREAM_ERRORzlib.constants.Z_DATA_ERRORzlib.constants.Z_MEM_ERRORzlib.constants.Z_BUF_ERRORzlib.constants.Z_VERSION_ERROR\n
Compression levels.
\n
zlib.constants.Z_NO_COMPRESSIONzlib.constants.Z_BEST_SPEEDzlib.constants.Z_BEST_COMPRESSIONzlib.constants.Z_DEFAULT_COMPRESSION\n
Compression strategy.
\n
zlib.constants.Z_FILTEREDzlib.constants.Z_HUFFMAN_ONLYzlib.constants.Z_RLEzlib.constants.Z_FIXEDzlib.constants.Z_DEFAULT_STRATEGY", "displayName": "zlib constants" }, { "textRaw": "Brotli constants", "name": "brotli_constants", "type": "misc", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "desc": "
There are several options and other constants available for Brotli-based\nstreams:
", "modules": [ { "textRaw": "Flush operations", "name": "flush_operations", "type": "module", "desc": "
The following values are valid flush operations for Brotli-based streams:
\n
zlib.constants.BROTLI_OPERATION_PROCESS (default for all operations)zlib.constants.BROTLI_OPERATION_FLUSH (default when calling .flush())zlib.constants.BROTLI_OPERATION_FINISH (default for the last chunk)zlib.constants.BROTLI_OPERATION_EMIT_METADATA\n", "displayName": "Flush operations" }, { "textRaw": "Compressor options", "name": "compressor_options", "type": "module", "desc": "
There are several options that can be set on Brotli encoders, affecting\ncompression efficiency and speed. Both the keys and the values can be accessed\nas properties of the zlib.constants object.
\n
The most important options are:
\n
BROTLI_PARAM_MODE\nBROTLI_MODE_GENERIC (default)BROTLI_MODE_TEXT, adjusted for UTF-8 textBROTLI_MODE_FONT, adjusted for WOFF 2.0 fontsBROTLI_PARAM_QUALITY\nBROTLI_MIN_QUALITY to BROTLI_MAX_QUALITY,\nwith a default of BROTLI_DEFAULT_QUALITY.BROTLI_PARAM_SIZE_HINT\n0 for an unknown input size.\n
The following flags can be set for advanced control over the compression\nalgorithm and memory usage tuning:
\n
BROTLI_PARAM_LGWIN\nBROTLI_MIN_WINDOW_BITS to BROTLI_MAX_WINDOW_BITS,\nwith a default of BROTLI_DEFAULT_WINDOW, or up to\nBROTLI_LARGE_MAX_WINDOW_BITS if the BROTLI_PARAM_LARGE_WINDOW flag\nis set.BROTLI_PARAM_LGBLOCK\nBROTLI_MIN_INPUT_BLOCK_BITS to BROTLI_MAX_INPUT_BLOCK_BITS.BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING\nBROTLI_PARAM_LARGE_WINDOW\nBROTLI_PARAM_NPOSTFIX\n0 to BROTLI_MAX_NPOSTFIX.BROTLI_PARAM_NDIRECT\n0 to 15 << NPOSTFIX in steps of 1 << NPOSTFIX.", "displayName": "Compressor options" }, { "textRaw": "Decompressor options", "name": "decompressor_options", "type": "module", "desc": "
These advanced options are available for controlling decompression:
\n
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION\nBROTLI_DECODER_PARAM_LARGE_WINDOW\n", "displayName": "Decompressor options" } ], "displayName": "Brotli constants" }, { "textRaw": "Zstd constants", "name": "zstd_constants", "type": "misc", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "desc": "
There are several options and other constants available for Zstd-based\nstreams:
", "modules": [ { "textRaw": "Flush operations", "name": "flush_operations", "type": "module", "desc": "
The following values are valid flush operations for Zstd-based streams:
\n
zlib.constants.ZSTD_e_continue (default for all operations)zlib.constants.ZSTD_e_flush (default when calling .flush())zlib.constants.ZSTD_e_end (default for the last chunk)", "displayName": "Flush operations" }, { "textRaw": "Compressor options", "name": "compressor_options", "type": "module", "desc": "
There are several options that can be set on Zstd encoders, affecting\ncompression efficiency and speed. Both the keys and the values can be accessed\nas properties of the zlib.constants object.
\n
The most important options are:
\n
ZSTD_c_compressionLevel\nZSTD_c_strategy\n", "displayName": "Compressor options" }, { "textRaw": "Strategy options", "name": "strategy_options", "type": "module", "desc": "
The following constants can be used as values for the ZSTD_c_strategy\nparameter:
\n
zlib.constants.ZSTD_fastzlib.constants.ZSTD_dfastzlib.constants.ZSTD_greedyzlib.constants.ZSTD_lazyzlib.constants.ZSTD_lazy2zlib.constants.ZSTD_btlazy2zlib.constants.ZSTD_btoptzlib.constants.ZSTD_btultrazlib.constants.ZSTD_btultra2\n
Example:
\n
const stream = zlib.createZstdCompress({\n params: {\n [zlib.constants.ZSTD_c_strategy]: zlib.constants.ZSTD_btultra,\n },\n});\n", "displayName": "Strategy options" }, { "textRaw": "Pledged Source Size", "name": "pledged_source_size", "type": "module", "desc": "
It's possible to specify the expected total size of the uncompressed input via\nopts.pledgedSrcSize. If the size doesn't match at the end of the input,\ncompression will fail with the code ZSTD_error_srcSize_wrong.
", "displayName": "Pledged Source Size" }, { "textRaw": "Decompressor options", "name": "decompressor_options", "type": "module", "desc": "
These advanced options are available for controlling decompression:
\n
ZSTD_d_windowLogMax\n", "displayName": "Decompressor options" } ], "displayName": "Zstd constants" } ] }, { "textRaw": "Class: `Options`", "name": "Options", "type": "misc", "meta": { "added": [ "v0.11.1" ], "changes": [ { "version": [ "v14.5.0", "v12.19.0" ], "pr-url": "https://github.com/nodejs/node/pull/33516", "description": "The `maxOutputLength` option is supported now." }, { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `dictionary` option can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `dictionary` option can be an `Uint8Array` now." }, { "version": "v5.11.0", "pr-url": "https://github.com/nodejs/node/pull/6069", "description": "The `finishFlush` option is supported now." } ] }, "desc": "
Each zlib-based class takes an options object. No options are required.
\n
Some options are only relevant when compressing and are\nignored by the decompression classes.
\n
flush <integer> Default: zlib.constants.Z_NO_FLUSHfinishFlush <integer> Default: zlib.constants.Z_FINISHchunkSize <integer> Default: 16 * 1024windowBits <integer>level <integer> (compression only)memLevel <integer> (compression only)strategy <integer> (compression only)dictionary <Buffer> | <TypedArray> | <DataView> | <ArrayBuffer> (deflate/inflate only,\nempty dictionary by default)info <boolean> (If true, returns an object with buffer and engine.)maxOutputLength <integer> Limits output size when using convenience methods. Default: buffer.kMaxLength\n
See the deflateInit2 and inflateInit2 documentation for more\ninformation.
" }, { "textRaw": "Class: `BrotliOptions`", "name": "BrotliOptions", "type": "misc", "meta": { "added": [ "v11.7.0" ], "changes": [ { "version": [ "v14.5.0", "v12.19.0" ], "pr-url": "https://github.com/nodejs/node/pull/33516", "description": "The `maxOutputLength` option is supported now." } ] }, "desc": "
Each Brotli-based class takes an options object. All options are optional.
\n
flush <integer> Default: zlib.constants.BROTLI_OPERATION_PROCESSfinishFlush <integer> Default: zlib.constants.BROTLI_OPERATION_FINISHchunkSize <integer> Default: 16 * 1024params <Object> Key-value object containing indexed Brotli parameters.maxOutputLength <integer> Limits output size when using convenience methods. Default: buffer.kMaxLengthinfo <boolean> If true, returns an object with buffer and engine. Default: false\n
For example:
\n
const stream = zlib.createBrotliCompress({\n chunkSize: 32 * 1024,\n params: {\n [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,\n [zlib.constants.BROTLI_PARAM_QUALITY]: 4,\n [zlib.constants.BROTLI_PARAM_SIZE_HINT]: fs.statSync(inputFile).size,\n },\n});\n" }, { "textRaw": "Class: `ZstdOptions`", "name": "ZstdOptions", "type": "misc", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "desc": "
Each Zstd-based class takes an options object. All options are optional.
\n
flush <integer> Default: zlib.constants.ZSTD_e_continuefinishFlush <integer> Default: zlib.constants.ZSTD_e_endchunkSize <integer> Default: 16 * 1024params <Object> Key-value object containing indexed Zstd parameters.maxOutputLength <integer> Limits output size when using convenience methods. Default: buffer.kMaxLengthinfo <boolean> If true, returns an object with buffer and engine. Default: falsedictionary <Buffer> Optional dictionary used to\nimprove compression efficiency when compressing or decompressing data that\nshares common patterns with the dictionary.\n
For example:
\n
const stream = zlib.createZstdCompress({\n chunkSize: 32 * 1024,\n params: {\n [zlib.constants.ZSTD_c_compressionLevel]: 10,\n [zlib.constants.ZSTD_c_checksumFlag]: 1,\n },\n});\n" }, { "textRaw": "Convenience methods", "name": "Convenience methods", "type": "misc", "desc": "
All of these take a <Buffer>, <TypedArray>, <DataView>, <ArrayBuffer>, or string\nas the first argument, an optional second argument\nto supply options to the zlib classes and will call the supplied callback\nwith callback(error, result).
\n
Every method has a *Sync counterpart, which accept the same arguments, but\nwithout a callback.
", "methods": [ { "textRaw": "`zlib.brotliCompress(buffer[, options], callback)`", "name": "brotliCompress", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.brotliCompressSync(buffer[, options])`", "name": "brotliCompressSync", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true } ] } ], "desc": "
Compress a chunk of data with BrotliCompress.
" }, { "textRaw": "`zlib.brotliDecompress(buffer[, options], callback)`", "name": "brotliDecompress", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.brotliDecompressSync(buffer[, options])`", "name": "brotliDecompressSync", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with BrotliDecompress.
" }, { "textRaw": "`zlib.deflate(buffer[, options], callback)`", "name": "deflate", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.deflateSync(buffer[, options])`", "name": "deflateSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Compress a chunk of data with Deflate.
" }, { "textRaw": "`zlib.deflateRaw(buffer[, options], callback)`", "name": "deflateRaw", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.deflateRawSync(buffer[, options])`", "name": "deflateRawSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Compress a chunk of data with DeflateRaw.
" }, { "textRaw": "`zlib.gunzip(buffer[, options], callback)`", "name": "gunzip", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.gunzipSync(buffer[, options])`", "name": "gunzipSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with Gunzip.
" }, { "textRaw": "`zlib.gzip(buffer[, options], callback)`", "name": "gzip", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.gzipSync(buffer[, options])`", "name": "gzipSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Compress a chunk of data with Gzip.
" }, { "textRaw": "`zlib.inflate(buffer[, options], callback)`", "name": "inflate", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.inflateSync(buffer[, options])`", "name": "inflateSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with Inflate.
" }, { "textRaw": "`zlib.inflateRaw(buffer[, options], callback)`", "name": "inflateRaw", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.inflateRawSync(buffer[, options])`", "name": "inflateRawSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with InflateRaw.
" }, { "textRaw": "`zlib.unzip(buffer[, options], callback)`", "name": "unzip", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.unzipSync(buffer[, options])`", "name": "unzipSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with Unzip.
" }, { "textRaw": "`zlib.zstdCompress(buffer[, options], callback)`", "name": "zstdCompress", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.zstdCompressSync(buffer[, options])`", "name": "zstdCompressSync", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true } ] } ], "desc": "
Compress a chunk of data with ZstdCompress.
" }, { "textRaw": "`zlib.zstdDecompress(buffer[, options], callback)`", "name": "zstdDecompress", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.zstdDecompressSync(buffer[, options])`", "name": "zstdDecompressSync", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with ZstdDecompress.
" } ] } ], "meta": { "added": [ "v0.5.8" ], "changes": [] }, "classes": [ { "textRaw": "Class: `zlib.BrotliCompress`", "name": "zlib.BrotliCompress", "type": "class", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "desc": "
ZlibBase\n
Compress data using the Brotli algorithm.
" }, { "textRaw": "Class: `zlib.BrotliDecompress`", "name": "zlib.BrotliDecompress", "type": "class", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "desc": "
ZlibBase\n
Decompress data using the Brotli algorithm.
" }, { "textRaw": "Class: `zlib.Deflate`", "name": "zlib.Deflate", "type": "class", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "desc": "
ZlibBase\n
Compress data using deflate.
" }, { "textRaw": "Class: `zlib.DeflateRaw`", "name": "zlib.DeflateRaw", "type": "class", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "desc": "
ZlibBase\n
Compress data using deflate, and do not append a zlib header.
" }, { "textRaw": "Class: `zlib.Gunzip`", "name": "zlib.Gunzip", "type": "class", "meta": { "added": [ "v0.5.8" ], "changes": [ { "version": "v6.0.0", "pr-url": "https://github.com/nodejs/node/pull/5883", "description": "Trailing garbage at the end of the input stream will now result in an `'error'` event." }, { "version": "v5.9.0", "pr-url": "https://github.com/nodejs/node/pull/5120", "description": "Multiple concatenated gzip file members are supported now." }, { "version": "v5.0.0", "pr-url": "https://github.com/nodejs/node/pull/2595", "description": "A truncated input stream will now result in an `'error'` event." } ] }, "desc": "
ZlibBase\n
Decompress a gzip stream.
" }, { "textRaw": "Class: `zlib.Gzip`", "name": "zlib.Gzip", "type": "class", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "desc": "
ZlibBase\n
Compress data using gzip.
" }, { "textRaw": "Class: `zlib.Inflate`", "name": "zlib.Inflate", "type": "class", "meta": { "added": [ "v0.5.8" ], "changes": [ { "version": "v5.0.0", "pr-url": "https://github.com/nodejs/node/pull/2595", "description": "A truncated input stream will now result in an `'error'` event." } ] }, "desc": "
ZlibBase\n
Decompress a deflate stream.
" }, { "textRaw": "Class: `zlib.InflateRaw`", "name": "zlib.InflateRaw", "type": "class", "meta": { "added": [ "v0.5.8" ], "changes": [ { "version": "v6.8.0", "pr-url": "https://github.com/nodejs/node/pull/8512", "description": "Custom dictionaries are now supported by `InflateRaw`." }, { "version": "v5.0.0", "pr-url": "https://github.com/nodejs/node/pull/2595", "description": "A truncated input stream will now result in an `'error'` event." } ] }, "desc": "
ZlibBase\n
Decompress a raw deflate stream.
" }, { "textRaw": "Class: `zlib.Unzip`", "name": "zlib.Unzip", "type": "class", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "desc": "
ZlibBase\n
Decompress either a Gzip- or Deflate-compressed stream by auto-detecting\nthe header.
" }, { "textRaw": "Class: `zlib.ZlibBase`", "name": "zlib.ZlibBase", "type": "class", "meta": { "added": [ "v0.5.8" ], "changes": [ { "version": [ "v11.7.0", "v10.16.0" ], "pr-url": "https://github.com/nodejs/node/pull/24939", "description": "This class was renamed from `Zlib` to `ZlibBase`." } ] }, "desc": "
stream.Transform\n
Not exported by the node:zlib module. It is documented here because it is the\nbase class of the compressor/decompressor classes.
\n
This class inherits from stream.Transform, allowing node:zlib objects to\nbe used in pipes and similar stream operations.
", "properties": [ { "textRaw": "Type: {number}", "name": "bytesWritten", "type": "number", "meta": { "added": [ "v10.0.0" ], "changes": [] }, "desc": "
The zlib.bytesWritten property specifies the number of bytes written to\nthe engine, before the bytes are processed (compressed or decompressed,\nas appropriate for the derived class).
" } ], "methods": [ { "textRaw": "`zlib.close([callback])`", "name": "close", "type": "method", "meta": { "added": [ "v0.9.4" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function", "optional": true } ] } ], "desc": "
Close the underlying handle.
" }, { "textRaw": "`zlib.flush([kind, ]callback)`", "name": "flush", "type": "method", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "signatures": [ { "params": [ { "name": "kind", "optional": true }, { "name": "callback" } ] } ], "desc": "
kind Default: zlib.constants.Z_FULL_FLUSH for zlib-based streams,\nzlib.constants.BROTLI_OPERATION_FLUSH for Brotli-based streams.callback <Function>\n
Flush pending data. Don't call this frivolously, premature flushes negatively\nimpact the effectiveness of the compression algorithm.
\n
Calling this only flushes data from the internal zlib state, and does not\nperform flushing of any kind on the streams level. Rather, it behaves like a\nnormal call to .write(), i.e. it will be queued up behind other pending\nwrites and will only produce output when data is being read from the stream.
" }, { "textRaw": "`zlib.params(level, strategy, callback)`", "name": "params", "type": "method", "meta": { "added": [ "v0.11.4" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`level` {integer}", "name": "level", "type": "integer" }, { "textRaw": "`strategy` {integer}", "name": "strategy", "type": "integer" }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ], "desc": "
This function is only available for zlib-based streams, i.e. not Brotli.
\n
Dynamically update the compression level and compression strategy.\nOnly applicable to deflate algorithm.
" }, { "textRaw": "`zlib.reset()`", "name": "reset", "type": "method", "meta": { "added": [ "v0.7.0" ], "changes": [] }, "signatures": [ { "params": [] } ], "desc": "
Reset the compressor/decompressor to factory defaults. Only applicable to\nthe inflate and deflate algorithms.
" } ] }, { "textRaw": "Class: `zlib.ZstdCompress`", "name": "zlib.ZstdCompress", "type": "class", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "desc": "
Compress data using the Zstd algorithm.
" }, { "textRaw": "Class: `zlib.ZstdDecompress`", "name": "zlib.ZstdDecompress", "type": "class", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "desc": "
Decompress data using the Zstd algorithm.
" } ], "properties": [ { "textRaw": "`zlib.constants`", "name": "constants", "type": "property", "meta": { "added": [ "v7.0.0" ], "changes": [] }, "desc": "
Provides an object enumerating Zlib-related constants.
" } ], "methods": [ { "textRaw": "`zlib.crc32(data[, value])`", "name": "crc32", "type": "method", "meta": { "added": [ "v22.2.0", "v20.15.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`data` {string|Buffer|TypedArray|DataView} When `data` is a string, it will be encoded as UTF-8 before being used for computation.", "name": "data", "type": "string|Buffer|TypedArray|DataView", "desc": "When `data` is a string, it will be encoded as UTF-8 before being used for computation." }, { "textRaw": "`value` {integer} An optional starting value. It must be a 32-bit unsigned integer. **Default:** `0`", "name": "value", "type": "integer", "default": "`0`", "desc": "An optional starting value. It must be a 32-bit unsigned integer.", "optional": true } ], "return": { "textRaw": "Returns: {integer} A 32-bit unsigned integer containing the checksum.", "name": "return", "type": "integer", "desc": "A 32-bit unsigned integer containing the checksum." } } ], "desc": "
Computes a 32-bit Cyclic Redundancy Check checksum of data. If\nvalue is specified, it is used as the starting value of the checksum,\notherwise, 0 is used as the starting value.
\n
The CRC algorithm is designed to compute checksums and to detect error\nin data transmission. It's not suitable for cryptographic authentication.
\n
To be consistent with other APIs, if the data is a string, it will\nbe encoded with UTF-8 before being used for computation. If users only\nuse Node.js to compute and match the checksums, this works well with\nother APIs that uses the UTF-8 encoding by default.
\n
Some third-party JavaScript libraries compute the checksum on a\nstring based on str.charCodeAt() so that it can be run in browsers.\nIf users want to match the checksum computed with this kind of library\nin the browser, it's better to use the same library in Node.js\nif it also runs in Node.js. If users have to use zlib.crc32() to\nmatch the checksum produced by such a third-party library:
\n
Uint8Array as input, use TextEncoder\nin the browser to encode the string into a Uint8Array with UTF-8\nencoding, and compute the checksum based on the UTF-8 encoded string\nin the browser.str.charCodeAt(), on the Node.js side, convert the string into\na buffer using Buffer.from(str, 'utf16le').\n
import zlib from 'node:zlib';\nimport { Buffer } from 'node:buffer';\n\nlet crc = zlib.crc32('hello'); // 907060870\ncrc = zlib.crc32('world', crc); // 4192936109\n\ncrc = zlib.crc32(Buffer.from('hello', 'utf16le')); // 1427272415\ncrc = zlib.crc32(Buffer.from('world', 'utf16le'), crc); // 4150509955\n\n
const zlib = require('node:zlib');\nconst { Buffer } = require('node:buffer');\n\nlet crc = zlib.crc32('hello'); // 907060870\ncrc = zlib.crc32('world', crc); // 4192936109\n\ncrc = zlib.crc32(Buffer.from('hello', 'utf16le')); // 1427272415\ncrc = zlib.crc32(Buffer.from('world', 'utf16le'), crc); // 4150509955\n" }, { "textRaw": "`zlib.createBrotliCompress([options])`", "name": "createBrotliCompress", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true } ] } ], "desc": "
Creates and returns a new BrotliCompress object.
" }, { "textRaw": "`zlib.createBrotliDecompress([options])`", "name": "createBrotliDecompress", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true } ] } ], "desc": "
Creates and returns a new BrotliDecompress object.
" }, { "textRaw": "`zlib.createDeflate([options])`", "name": "createDeflate", "type": "method", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Creates and returns a new Deflate object.
" }, { "textRaw": "`zlib.createDeflateRaw([options])`", "name": "createDeflateRaw", "type": "method", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Creates and returns a new DeflateRaw object.
\n
An upgrade of zlib from 1.2.8 to 1.2.11 changed behavior when windowBits\nis set to 8 for raw deflate streams. zlib would automatically set windowBits\nto 9 if was initially set to 8. Newer versions of zlib will throw an exception,\nso Node.js restored the original behavior of upgrading a value of 8 to 9,\nsince passing windowBits = 9 to zlib actually results in a compressed stream\nthat effectively uses an 8-bit window only.
" }, { "textRaw": "`zlib.createGunzip([options])`", "name": "createGunzip", "type": "method", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Creates and returns a new Gunzip object.
" }, { "textRaw": "`zlib.createGzip([options])`", "name": "createGzip", "type": "method", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Creates and returns a new Gzip object.\nSee example.
" }, { "textRaw": "`zlib.createInflate([options])`", "name": "createInflate", "type": "method", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Creates and returns a new Inflate object.
" }, { "textRaw": "`zlib.createInflateRaw([options])`", "name": "createInflateRaw", "type": "method", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Creates and returns a new InflateRaw object.
" }, { "textRaw": "`zlib.createUnzip([options])`", "name": "createUnzip", "type": "method", "meta": { "added": [ "v0.5.8" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Creates and returns a new Unzip object.
" }, { "textRaw": "`zlib.createZstdCompress([options])`", "name": "createZstdCompress", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "signatures": [ { "params": [ { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true } ] } ], "desc": "
Creates and returns a new ZstdCompress object.
" }, { "textRaw": "`zlib.createZstdDecompress([options])`", "name": "createZstdDecompress", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "signatures": [ { "params": [ { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true } ] } ], "desc": "
Creates and returns a new ZstdDecompress object.
" }, { "textRaw": "`zlib.brotliCompress(buffer[, options], callback)`", "name": "brotliCompress", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.brotliCompressSync(buffer[, options])`", "name": "brotliCompressSync", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true } ] } ], "desc": "
Compress a chunk of data with BrotliCompress.
" }, { "textRaw": "`zlib.brotliDecompress(buffer[, options], callback)`", "name": "brotliDecompress", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.brotliDecompressSync(buffer[, options])`", "name": "brotliDecompressSync", "type": "method", "meta": { "added": [ "v11.7.0", "v10.16.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {brotli options}", "name": "options", "type": "brotli options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with BrotliDecompress.
" }, { "textRaw": "`zlib.deflate(buffer[, options], callback)`", "name": "deflate", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.deflateSync(buffer[, options])`", "name": "deflateSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Compress a chunk of data with Deflate.
" }, { "textRaw": "`zlib.deflateRaw(buffer[, options], callback)`", "name": "deflateRaw", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.deflateRawSync(buffer[, options])`", "name": "deflateRawSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Compress a chunk of data with DeflateRaw.
" }, { "textRaw": "`zlib.gunzip(buffer[, options], callback)`", "name": "gunzip", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.gunzipSync(buffer[, options])`", "name": "gunzipSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with Gunzip.
" }, { "textRaw": "`zlib.gzip(buffer[, options], callback)`", "name": "gzip", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.gzipSync(buffer[, options])`", "name": "gzipSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Compress a chunk of data with Gzip.
" }, { "textRaw": "`zlib.inflate(buffer[, options], callback)`", "name": "inflate", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.inflateSync(buffer[, options])`", "name": "inflateSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with Inflate.
" }, { "textRaw": "`zlib.inflateRaw(buffer[, options], callback)`", "name": "inflateRaw", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.inflateRawSync(buffer[, options])`", "name": "inflateRawSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with InflateRaw.
" }, { "textRaw": "`zlib.unzip(buffer[, options], callback)`", "name": "unzip", "type": "method", "meta": { "added": [ "v0.6.0" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.unzipSync(buffer[, options])`", "name": "unzipSync", "type": "method", "meta": { "added": [ "v0.11.12" ], "changes": [ { "version": "v9.4.0", "pr-url": "https://github.com/nodejs/node/pull/16042", "description": "The `buffer` parameter can be an `ArrayBuffer`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12223", "description": "The `buffer` parameter can be any `TypedArray` or `DataView`." }, { "version": "v8.0.0", "pr-url": "https://github.com/nodejs/node/pull/12001", "description": "The `buffer` parameter can be an `Uint8Array` now." } ] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zlib options}", "name": "options", "type": "zlib options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with Unzip.
" }, { "textRaw": "`zlib.zstdCompress(buffer[, options], callback)`", "name": "zstdCompress", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.zstdCompressSync(buffer[, options])`", "name": "zstdCompressSync", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true } ] } ], "desc": "
Compress a chunk of data with ZstdCompress.
" }, { "textRaw": "`zlib.zstdDecompress(buffer[, options], callback)`", "name": "zstdDecompress", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true }, { "textRaw": "`callback` {Function}", "name": "callback", "type": "Function" } ] } ] }, { "textRaw": "`zlib.zstdDecompressSync(buffer[, options])`", "name": "zstdDecompressSync", "type": "method", "meta": { "added": [ "v23.8.0", "v22.15.0" ], "changes": [] }, "stability": 1, "stabilityText": "Experimental", "signatures": [ { "params": [ { "textRaw": "`buffer` {Buffer|TypedArray|DataView|ArrayBuffer|string}", "name": "buffer", "type": "Buffer|TypedArray|DataView|ArrayBuffer|string" }, { "textRaw": "`options` {zstd options}", "name": "options", "type": "zstd options", "optional": true } ] } ], "desc": "
Decompress a chunk of data with ZstdDecompress.
" } ], "displayName": "Zlib" } ] }