zlib.constants属性用于产生列出与Zlib相关的常量的对象。
用法:
zlib.constants
返回值:它返回所有与Zlib相关的常量。
以下示例说明了Node.js中zlib.constants属性的使用:
范例1:
// Node.js program to demonstrate
// zlib.constants property
// Including zlib module
const zlib = require("zlib");
// Creating a buffer
const buffer = Buffer.from('eJzT0yMA', 'base64');
// Calling unzip method
zlib.unzip(
buffer,
// Using a Zlib constant
{ finishFlush:zlib.constants.Z_SYNC_FLUSH },
(err, buffer) => {
if (!err) {
console.log(buffer.toString());
}
else
{
console.log(err);
}
});
// Calling "constants" property of zlib
zlib.constants;
输出:
[Object:null prototype] { Z_NO_FLUSH:0, Z_PARTIAL_FLUSH:1, Z_SYNC_FLUSH:2, Z_FULL_FLUSH:3, Z_FINISH:4, Z_BLOCK:5, Z_OK:0, Z_STREAM_END:1, Z_NEED_DICT:2, Z_ERRNO:-1, Z_STREAM_ERROR:-2, Z_DATA_ERROR:-3, Z_MEM_ERROR:-4, Z_BUF_ERROR:-5, Z_VERSION_ERROR:-6, Z_NO_COMPRESSION:0, Z_BEST_SPEED:1, Z_BEST_COMPRESSION:9, Z_DEFAULT_COMPRESSION:-1, Z_FILTERED:1, Z_HUFFMAN_ONLY:2, Z_RLE:3, Z_FIXED:4, Z_DEFAULT_STRATEGY:0, ZLIB_VERNUM:4784, DEFLATE:1, INFLATE:2, GZIP:3, GUNZIP:4, DEFLATERAW:5, INFLATERAW:6, UNZIP:7, BROTLI_DECODE:8, BROTLI_ENCODE:9, Z_MIN_WINDOWBITS:8, Z_MAX_WINDOWBITS:15, Z_DEFAULT_WINDOWBITS:15, Z_MIN_CHUNK:64, Z_MAX_CHUNK:Infinity, Z_DEFAULT_CHUNK:16384, Z_MIN_MEMLEVEL:1, Z_MAX_MEMLEVEL:9, Z_DEFAULT_MEMLEVEL:8, Z_MIN_LEVEL:-1, Z_MAX_LEVEL:9, Z_DEFAULT_LEVEL:-1, BROTLI_OPERATION_PROCESS:0, BROTLI_OPERATION_FLUSH:1, BROTLI_OPERATION_FINISH:2, BROTLI_OPERATION_EMIT_METADATA:3, BROTLI_PARAM_MODE:0, BROTLI_MODE_GENERIC:0, BROTLI_MODE_TEXT:1, BROTLI_MODE_FONT:2, BROTLI_DEFAULT_MODE:0, BROTLI_PARAM_QUALITY:1, BROTLI_MIN_QUALITY:0, BROTLI_MAX_QUALITY:11, BROTLI_DEFAULT_QUALITY:11, BROTLI_PARAM_LGWIN:2, BROTLI_MIN_WINDOW_BITS:10, BROTLI_MAX_WINDOW_BITS:24, BROTLI_LARGE_MAX_WINDOW_BITS:30, BROTLI_DEFAULT_WINDOW:22, BROTLI_PARAM_LGBLOCK:3, BROTLI_MIN_INPUT_BLOCK_BITS:16, BROTLI_MAX_INPUT_BLOCK_BITS:24, BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4, BROTLI_PARAM_SIZE_HINT:5, BROTLI_PARAM_LARGE_WINDOW:6, BROTLI_PARAM_NPOSTFIX:7, BROTLI_PARAM_NDIRECT:8, BROTLI_DECODER_RESULT_ERROR:0, BROTLI_DECODER_RESULT_SUCCESS:1, BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2, BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3, BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0, BROTLI_DECODER_PARAM_LARGE_WINDOW:1, BROTLI_DECODER_NO_ERROR:0, BROTLI_DECODER_SUCCESS:1, BROTLI_DECODER_NEEDS_MORE_INPUT:2, BROTLI_DECODER_NEEDS_MORE_OUTPUT:3, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1, BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5, BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6, BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7, BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10, BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11, BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12, BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13, BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14, BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15, BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16, BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19, BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21, BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27, BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30, BROTLI_DECODER_ERROR_UNREACHABLE:-31 } ..
范例2:
// Node.js program to demonstrate
// zlib.constants property
// Including zlib module
const zlib = require("zlib");
// Creating a buffer
const buffer = Buffer.from('eJzT0yMA', 'base64');
// Calling unzip method
zlib.unzip(
buffer,
// Using a different Zlib constant
{ finishFlush:zlib.constants.Z_NO_FLUSH },
(err, buffer) => {
if (!err) {
console.log(buffer.toString());
}
else
{
console.log(err);
}
});
// Calling "constants" property of zlib
zlib.constants;
输出
[Object:null prototype] { Z_NO_FLUSH:0, Z_PARTIAL_FLUSH:1, Z_SYNC_FLUSH:2, Z_FULL_FLUSH:3, Z_FINISH:4, Z_BLOCK:5, Z_OK:0, Z_STREAM_END:1, Z_NEED_DICT:2, Z_ERRNO:-1, Z_STREAM_ERROR:-2, Z_DATA_ERROR:-3, Z_MEM_ERROR:-4, Z_BUF_ERROR:-5, Z_VERSION_ERROR:-6, Z_NO_COMPRESSION:0, Z_BEST_SPEED:1, Z_BEST_COMPRESSION:9, Z_DEFAULT_COMPRESSION:-1, Z_FILTERED:1, Z_HUFFMAN_ONLY:2, Z_RLE:3, Z_FIXED:4, Z_DEFAULT_STRATEGY:0, ZLIB_VERNUM:4784, DEFLATE:1, INFLATE:2, GZIP:3, GUNZIP:4, DEFLATERAW:5, INFLATERAW:6, UNZIP:7, BROTLI_DECODE:8, BROTLI_ENCODE:9, Z_MIN_WINDOWBITS:8, Z_MAX_WINDOWBITS:15, Z_DEFAULT_WINDOWBITS:15, Z_MIN_CHUNK:64, Z_MAX_CHUNK:Infinity, Z_DEFAULT_CHUNK:16384, Z_MIN_MEMLEVEL:1, Z_MAX_MEMLEVEL:9, Z_DEFAULT_MEMLEVEL:8, Z_MIN_LEVEL:-1, Z_MAX_LEVEL:9, Z_DEFAULT_LEVEL:-1, BROTLI_OPERATION_PROCESS:0, BROTLI_OPERATION_FLUSH:1, BROTLI_OPERATION_FINISH:2, BROTLI_OPERATION_EMIT_METADATA:3, BROTLI_PARAM_MODE:0, BROTLI_MODE_GENERIC:0, BROTLI_MODE_TEXT:1, BROTLI_MODE_FONT:2, BROTLI_DEFAULT_MODE:0, BROTLI_PARAM_QUALITY:1, BROTLI_MIN_QUALITY:0, BROTLI_MAX_QUALITY:11, BROTLI_DEFAULT_QUALITY:11, BROTLI_PARAM_LGWIN:2, BROTLI_MIN_WINDOW_BITS:10, BROTLI_MAX_WINDOW_BITS:24, BROTLI_LARGE_MAX_WINDOW_BITS:30, BROTLI_DEFAULT_WINDOW:22, BROTLI_PARAM_LGBLOCK:3, BROTLI_MIN_INPUT_BLOCK_BITS:16, BROTLI_MAX_INPUT_BLOCK_BITS:24, BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4, BROTLI_PARAM_SIZE_HINT:5, BROTLI_PARAM_LARGE_WINDOW:6, BROTLI_PARAM_NPOSTFIX:7, BROTLI_PARAM_NDIRECT:8, BROTLI_DECODER_RESULT_ERROR:0, BROTLI_DECODER_RESULT_SUCCESS:1, BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2, BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3, BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0, BROTLI_DECODER_PARAM_LARGE_WINDOW:1, BROTLI_DECODER_NO_ERROR:0, BROTLI_DECODER_SUCCESS:1, BROTLI_DECODER_NEEDS_MORE_INPUT:2, BROTLI_DECODER_NEEDS_MORE_OUTPUT:3, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1, BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2, BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4, BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5, BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6, BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7, BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9, BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10, BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11, BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12, BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13, BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14, BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15, BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16, BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19, BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21, BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22, BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26, BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27, BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30, BROTLI_DECODER_ERROR_UNREACHABLE:-31 } ..
参考: https://nodejs.org/api/zlib.html#zlib_zlib_constants_1
相关用法
- Node.js GM whiteThreshold()用法及代码示例
- Node.js GM transparent()用法及代码示例
- Node.js GM modulate()用法及代码示例
- Node.js GM monochrome()用法及代码示例
- Node.js GM equalize()用法及代码示例
- Node.js GM thumbnail()用法及代码示例
- Node.js GM whitePoint()用法及代码示例
- Node.js GM write()用法及代码示例
- Node.js GM minify()用法及代码示例
- Node.js GM magnify()用法及代码示例
注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Node.js | zlib.constants Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。