node:zlib
#Import
import zlib from "nstdlib/node/zlib";Note
The API is available, but not everything works. No compression binding, so every stream and one-shot throws ERR_NSTDLIB_NO_BINDING. The 154 exports and all of constants and codes are real and compared against the host builtin. crc32 is a checksum rather than a codec and is implemented. native/ backs Zlib and BrotliDecoder on node_binding_zlib_*, over the zlib and the brotli decoder compiled into that binary. The Brotli encoder and both directions of Zstandard stay refused there too.
#Support
- nstd: Gives the same output as Node.js in side-by-side tests: zlib.
- Browser: Loads with a minimal
processobject. 162 of Node's 162 exports are available. 1 of 1 behavior checks match Node.js.
#Exports (162)
Every name Node.js exports from this module, and what you get when you read it, as a named import or as a property of the default import:
- ✅ A value, both ways. An export that throws an error naming the missing feature also counts.
- ⚠️ A value one way,
undefinedthe other. - ❔
undefinedboth ways. - ❌ Not exported at all.
- – Not measured.
Show all 162 exports
| Export | Node.js | Browser |
|---|---|---|
BrotliCompress | ✅ | ✅ |
BrotliDecompress | ✅ | ✅ |
DEFLATE | ✅ | ✅ |
DEFLATERAW | ✅ | ✅ |
Deflate | ✅ | ✅ |
DeflateRaw | ✅ | ✅ |
GUNZIP | ✅ | ✅ |
GZIP | ✅ | ✅ |
Gunzip | ✅ | ✅ |
Gzip | ✅ | ✅ |
INFLATE | ✅ | ✅ |
INFLATERAW | ✅ | ✅ |
Inflate | ✅ | ✅ |
InflateRaw | ✅ | ✅ |
UNZIP | ✅ | ✅ |
Unzip | ✅ | ✅ |
ZLIB_VERNUM | ✅ | ✅ |
ZSTD_CLEVEL_DEFAULT | ✅ | ✅ |
ZSTD_COMPRESS | ✅ | ✅ |
ZSTD_DECOMPRESS | ✅ | ✅ |
ZSTD_btlazy2 | ✅ | ✅ |
ZSTD_btopt | ✅ | ✅ |
ZSTD_btultra | ✅ | ✅ |
ZSTD_btultra2 | ✅ | ✅ |
ZSTD_c_chainLog | ✅ | ✅ |
ZSTD_c_checksumFlag | ✅ | ✅ |
ZSTD_c_compressionLevel | ✅ | ✅ |
ZSTD_c_contentSizeFlag | ✅ | ✅ |
ZSTD_c_dictIDFlag | ✅ | ✅ |
ZSTD_c_enableLongDistanceMatching | ✅ | ✅ |
ZSTD_c_hashLog | ✅ | ✅ |
ZSTD_c_jobSize | ✅ | ✅ |
ZSTD_c_ldmBucketSizeLog | ✅ | ✅ |
ZSTD_c_ldmHashLog | ✅ | ✅ |
ZSTD_c_ldmHashRateLog | ✅ | ✅ |
ZSTD_c_ldmMinMatch | ✅ | ✅ |
ZSTD_c_minMatch | ✅ | ✅ |
ZSTD_c_nbWorkers | ✅ | ✅ |
ZSTD_c_overlapLog | ✅ | ✅ |
ZSTD_c_searchLog | ✅ | ✅ |
ZSTD_c_strategy | ✅ | ✅ |
ZSTD_c_targetLength | ✅ | ✅ |
ZSTD_c_windowLog | ✅ | ✅ |
ZSTD_d_windowLogMax | ✅ | ✅ |
ZSTD_dfast | ✅ | ✅ |
ZSTD_e_continue | ✅ | ✅ |
ZSTD_e_end | ✅ | ✅ |
ZSTD_e_flush | ✅ | ✅ |
ZSTD_error_GENERIC | ✅ | ✅ |
ZSTD_error_checksum_wrong | ✅ | ✅ |
ZSTD_error_corruption_detected | ✅ | ✅ |
ZSTD_error_dictionaryCreation_failed | ✅ | ✅ |
ZSTD_error_dictionary_corrupted | ✅ | ✅ |
ZSTD_error_dictionary_wrong | ✅ | ✅ |
ZSTD_error_dstBuffer_null | ✅ | ✅ |
ZSTD_error_dstSize_tooSmall | ✅ | ✅ |
ZSTD_error_frameParameter_unsupported | ✅ | ✅ |
ZSTD_error_frameParameter_windowTooLarge | ✅ | ✅ |
ZSTD_error_init_missing | ✅ | ✅ |
ZSTD_error_literals_headerWrong | ✅ | ✅ |
ZSTD_error_maxSymbolValue_tooLarge | ✅ | ✅ |
ZSTD_error_maxSymbolValue_tooSmall | ✅ | ✅ |
ZSTD_error_memory_allocation | ✅ | ✅ |
ZSTD_error_noForwardProgress_destFull | ✅ | ✅ |
ZSTD_error_noForwardProgress_inputEmpty | ✅ | ✅ |
ZSTD_error_no_error | ✅ | ✅ |
ZSTD_error_parameter_combination_unsupported | ✅ | ✅ |
ZSTD_error_parameter_outOfBound | ✅ | ✅ |
ZSTD_error_parameter_unsupported | ✅ | ✅ |
ZSTD_error_prefix_unknown | ✅ | ✅ |
ZSTD_error_srcSize_wrong | ✅ | ✅ |
ZSTD_error_stabilityCondition_notRespected | ✅ | ✅ |
ZSTD_error_stage_wrong | ✅ | ✅ |
ZSTD_error_tableLog_tooLarge | ✅ | ✅ |
ZSTD_error_version_unsupported | ✅ | ✅ |
ZSTD_error_workSpace_tooSmall | ✅ | ✅ |
ZSTD_fast | ✅ | ✅ |
ZSTD_greedy | ✅ | ✅ |
ZSTD_lazy | ✅ | ✅ |
ZSTD_lazy2 | ✅ | ✅ |
Z_BEST_COMPRESSION | ✅ | ✅ |
Z_BEST_SPEED | ✅ | ✅ |
Z_BLOCK | ✅ | ✅ |
Z_BUF_ERROR | ✅ | ✅ |
Z_DATA_ERROR | ✅ | ✅ |
Z_DEFAULT_CHUNK | ✅ | ✅ |
Z_DEFAULT_COMPRESSION | ✅ | ✅ |
Z_DEFAULT_LEVEL | ✅ | ✅ |
Z_DEFAULT_MEMLEVEL | ✅ | ✅ |
Z_DEFAULT_STRATEGY | ✅ | ✅ |
Z_DEFAULT_WINDOWBITS | ✅ | ✅ |
Z_ERRNO | ✅ | ✅ |
Z_FILTERED | ✅ | ✅ |
Z_FINISH | ✅ | ✅ |
Z_FIXED | ✅ | ✅ |
Z_FULL_FLUSH | ✅ | ✅ |
Z_HUFFMAN_ONLY | ✅ | ✅ |
Z_MAX_CHUNK | ✅ | ✅ |
Z_MAX_LEVEL | ✅ | ✅ |
Z_MAX_MEMLEVEL | ✅ | ✅ |
Z_MAX_WINDOWBITS | ✅ | ✅ |
Z_MEM_ERROR | ✅ | ✅ |
Z_MIN_CHUNK | ✅ | ✅ |
Z_MIN_LEVEL | ✅ | ✅ |
Z_MIN_MEMLEVEL | ✅ | ✅ |
Z_MIN_WINDOWBITS | ✅ | ✅ |
Z_NEED_DICT | ✅ | ✅ |
Z_NO_COMPRESSION | ✅ | ✅ |
Z_NO_FLUSH | ✅ | ✅ |
Z_OK | ✅ | ✅ |
Z_PARTIAL_FLUSH | ✅ | ✅ |
Z_RLE | ✅ | ✅ |
Z_STREAM_END | ✅ | ✅ |
Z_STREAM_ERROR | ✅ | ✅ |
Z_SYNC_FLUSH | ✅ | ✅ |
Z_VERSION_ERROR | ✅ | ✅ |
ZipBuffer | ✅ | ✅ |
ZipEntry | ✅ | ✅ |
ZipFile | ✅ | ✅ |
ZstdCompress | ✅ | ✅ |
ZstdDecompress | ✅ | ✅ |
brotliCompress | ✅ | ✅ |
brotliCompressSync | ✅ | ✅ |
brotliDecompress | ✅ | ✅ |
brotliDecompressSync | ✅ | ✅ |
codes | ✅ | ✅ |
constants | ✅ | ✅ |
crc32 | ✅ | ✅ |
createBrotliCompress | ✅ | ✅ |
createBrotliDecompress | ✅ | ✅ |
createDeflate | ✅ | ✅ |
createDeflateRaw | ✅ | ✅ |
createGunzip | ✅ | ✅ |
createGzip | ✅ | ✅ |
createInflate | ✅ | ✅ |
createInflateRaw | ✅ | ✅ |
createUnzip | ✅ | ✅ |
createZipArchive | ✅ | ✅ |
createZipArchiveSync | ✅ | ✅ |
createZstdCompress | ✅ | ✅ |
createZstdDecompress | ✅ | ✅ |
deflate | ✅ | ✅ |
deflateRaw | ✅ | ✅ |
deflateRawSync | ✅ | ✅ |
deflateSync | ✅ | ✅ |
getMaxZipContentSize | ✅ | ✅ |
gunzip | ✅ | ✅ |
gunzipSync | ✅ | ✅ |
gzip | ✅ | ✅ |
gzipSync | ✅ | ✅ |
inflate | ✅ | ✅ |
inflateRaw | ✅ | ✅ |
inflateRawSync | ✅ | ✅ |
inflateSync | ✅ | ✅ |
setMaxZipContentSize | ✅ | ✅ |
unzip | ✅ | ✅ |
unzipSync | ✅ | ✅ |
zipFiles | ✅ | ✅ |
zstdCompress | ✅ | ✅ |
zstdCompressSync | ✅ | ✅ |
zstdDecompress | ✅ | ✅ |
zstdDecompressSync | ✅ | ✅ |
#Diagnostics
nstdlib running inside Node.js. This isn't an environment it's meant for, so it isn't shown above, but it tells a library problem from an environment one:
coverage: 162/162 of the host's export names answer inside host node. API only. No compression binding, so every stream and one-shot throwsERR_NSTDLIB_NO_BINDING. The 154 exports and all ofconstantsandcodesare real and compared against the host builtin.crc32is a checksum rather than a codec and is implemented.native/backsZlibandBrotliDecoderonnode_binding_zlib_*, over the zlib and the brotli decoder compiled into that binary. The Brotli encoder and both directions of Zstandard stay refused there too.smoke: Imports in a clean child process.node-suite: 46/85 of Node's own eligible tests pass with ./dist inside host node. A failure there and in the page is the library's, one only in the page is the engine's.wasm-differentials: Zlib: pass against the host's own builtin withnstdlib-wasm's blob installed. The published binding refuses without it. Ok nstdlib/node/zlib on Zlib + crc32 == the host's node:zlib.wasm-differentials: Brotli: pass against the host's own builtin withnstdlib-wasm's blob installed. The published binding refuses without it. Ok nstdlib/node/zlib on BrotliEncoder + BrotliDecoder == the host's node:zlib.wasm-differentials: Zstd: pass against the host's own builtin withnstdlib-wasm's blob installed. The published binding refuses without it. Ok nstdlib/node/zlib on ZstdCompress + ZstdDecompress == the host's node:zlib.