zlib 常量


【zlib constants】

zlib.h 中定义的所有常量也都在 require('node:zlib').constants 中定义。在正常操作过程中,通常不需要使用这些常量。它们的文档是为了让它们的存在不令人惊讶。该部分几乎直接摘自 zlib 文档

【All of the constants defined in zlib.h are also defined on require('node:zlib').constants. In the normal course of operations, it will not be necessary to use these constants. They are documented so that their presence is not surprising. This section is taken almost directly from the zlib documentation.】

以前,这些常量可以直接从 require('node:zlib') 获取,例如 zlib.Z_NO_FLUSH。目前仍然可以直接从模块访问这些常量,但这种做法已被弃用。

【Previously, the constants were available directly from require('node:zlib'), for instance zlib.Z_NO_FLUSH. Accessing the constants directly from the module is currently still possible but is deprecated.】

允许的刷新值。

【Allowed flush values.】

  • zlib.constants.Z_NO_FLUSH
  • zlib.constants.Z_PARTIAL_FLUSH
  • zlib.constants.Z_SYNC_FLUSH
  • zlib.constants.Z_FULL_FLUSH
  • zlib.constants.Z_FINISH
  • zlib.constants.Z_BLOCK

压缩/解压缩函数的返回码。负值表示错误,正值表示特殊但正常的事件。

【Return codes for the compression/decompression functions. Negative values are errors, positive values are used for special but normal events.】

  • zlib.constants.Z_OK
  • zlib.constants.Z_STREAM_END
  • zlib.constants.Z_NEED_DICT
  • zlib.constants.Z_ERRNO
  • zlib.constants.Z_STREAM_ERROR
  • zlib.constants.Z_DATA_ERROR
  • zlib.constants.Z_MEM_ERROR
  • zlib.constants.Z_BUF_ERROR
  • zlib.constants.Z_VERSION_ERROR

压缩级别。

【Compression levels.】

  • zlib.constants.Z_NO_COMPRESSION
  • zlib.constants.Z_BEST_SPEED
  • zlib.constants.Z_BEST_COMPRESSION
  • zlib.constants.Z_DEFAULT_COMPRESSION

压缩策略。

【Compression strategy.】

  • zlib.constants.Z_FILTERED
  • zlib.constants.Z_HUFFMAN_ONLY
  • zlib.constants.Z_RLE
  • zlib.constants.Z_FIXED
  • zlib.constants.Z_DEFAULT_STRATEGY