node:zlib
The node:zlib module in Azion Runtime: the compression functions that throw inside a function, and the Web API that compresses data instead.
The node:zlib module compresses and decompresses data with the Gzip, Deflate, and Brotli algorithms, and Node.js builds it on the zlib library, as the Node.js zlib documentation describes. In Azion Runtime, import zlib from "node:zlib" builds, and zlib.constants is an object, in a deployed function and under azion dev.
The compression functions are not implemented, so nothing in the module compresses data. Each one throws an Error or passes one to its callback, with the same message in a deployed function and under azion dev.
To compress data in a function, use the Web CompressionStream API, which works in both environments. A new CompressionStream('gzip') stream compresses the data, and a new DecompressionStream('gzip') stream restores it. The constructor accepts gzip, deflate, and deflate-raw, and throws a TypeError for br. For more information, refer to Web APIs.
Methods
The table lists each compression function and the error it produces:
| Call | Result |
|---|---|
zlib.gzipSync(data) | Throws Error: [unenv] zlib.gzipSync is not implemented yet! |
zlib.deflateSync(data) | Throws Error: [unenv] zlib.deflateSync is not implemented yet! |
zlib.deflateRawSync(data) | Throws Error: [unenv] zlib.deflateRawSync is not implemented yet! |
zlib.brotliCompressSync(data) | Throws Error: [unenv] zlib.brotliCompressSync is not implemented yet! |
zlib.gzip(data, callback) | Calls callback with Error: [unenv] zlib gzip compression not supported. |
zlib.createGzip() | Throws Error: [unenv] zlib is not implemented yet! is not implemented yet! |