Skip to content

Commit b7c9320

Browse files
authored
update constants bindings
1 parent 8b3f0a8 commit b7c9320

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/index.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,33 @@ for (var bk = 0; bk < bkeys.length; bk++) {
4141
}
4242
}
4343

44+
const constants = process.binding('constants').zlib;
45+
const {
46+
// Zlib flush levels
47+
Z_NO_FLUSH, Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_FINISH,
48+
// Zlib option values
49+
Z_MIN_CHUNK, Z_MIN_WINDOWBITS, Z_MAX_WINDOWBITS, Z_MIN_LEVEL, Z_MAX_LEVEL,
50+
Z_MIN_MEMLEVEL, Z_MAX_MEMLEVEL, Z_DEFAULT_CHUNK, Z_DEFAULT_COMPRESSION,
51+
Z_DEFAULT_STRATEGY, Z_DEFAULT_WINDOWBITS, Z_DEFAULT_MEMLEVEL, Z_FIXED,
52+
// Node's compression stream modes (node_zlib_mode)
53+
DEFLATE, DEFLATERAW, INFLATE, INFLATERAW, GZIP, GUNZIP, UNZIP,
54+
BROTLI_DECODE, BROTLI_ENCODE,
55+
// Brotli operations (~flush levels)
56+
BROTLI_OPERATION_PROCESS, BROTLI_OPERATION_FLUSH,
57+
BROTLI_OPERATION_FINISH
58+
} = constants;
59+
4460
// translation table for return codes.
4561
const codes = {
46-
Z_OK: binding.Z_OK,
47-
Z_STREAM_END: binding.Z_STREAM_END,
48-
Z_NEED_DICT: binding.Z_NEED_DICT,
49-
Z_ERRNO: binding.Z_ERRNO,
50-
Z_STREAM_ERROR: binding.Z_STREAM_ERROR,
51-
Z_DATA_ERROR: binding.Z_DATA_ERROR,
52-
Z_MEM_ERROR: binding.Z_MEM_ERROR,
53-
Z_BUF_ERROR: binding.Z_BUF_ERROR,
54-
Z_VERSION_ERROR: binding.Z_VERSION_ERROR
62+
Z_OK: constants.Z_OK,
63+
Z_STREAM_END: constants.Z_STREAM_END,
64+
Z_NEED_DICT: constants.Z_NEED_DICT,
65+
Z_ERRNO: constants.Z_ERRNO,
66+
Z_STREAM_ERROR: constants.Z_STREAM_ERROR,
67+
Z_DATA_ERROR: constants.Z_DATA_ERROR,
68+
Z_MEM_ERROR: constants.Z_MEM_ERROR,
69+
Z_BUF_ERROR: constants.Z_BUF_ERROR,
70+
Z_VERSION_ERROR: constants.Z_VERSION_ERROR
5571
};
5672

5773
const ckeys = Object.keys(codes);

0 commit comments

Comments
 (0)