Skip to content

Commit f7c98c2

Browse files
authored
Compatibility with node 20.x.x
2 parents 8abf5b9 + 1b12d9e commit f7c98c2

5 files changed

Lines changed: 21 additions & 7 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
.idea/
12
build/
23
lib/compress-buffer/compress-buffer-bindings.node
34
.lock-wscript
45
nbproject/
56
node_modules/*
7+
package-lock.json

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
4.0.0: Nov 02, 2023
2+
* compatibility with node 20.x.x
3+
14
1.2.0: Mar 22, 2013
25
* compatibility with node 0.10.0 (converted to GYP)
36

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"bugs": {
66
"url": "http://github.com/egorFiNE/node-compress-buffer/issues"
77
},
8-
"version": "3.0.0",
8+
"version": "4.0.0",
99
"author": "Egor Egorov",
1010
"repository": {
1111
"type": "git",

src/compress-buffer.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#define WBITS 16+MAX_WBITS
1616
#define WBITS_RAW -15
1717

18+
#ifdef Z_LARGE64 // zlib defines different functions depending on architecture.
19+
#pragma message "Z_LARGE64 defined using crc32_combine64"
20+
#define ZLIB_CRC32_COMBINE(crc1, crc2, len2) crc32_combine64((crc1), (crc2), (len2))
21+
#else
22+
#define ZLIB_CRC32_COMBINE(crc1, crc2, len2) crc32_combine((crc1), (crc2), (len2))
23+
#pragma message "Z_LARGE64 NOT defined using crc32_combine"
24+
#endif
25+
1826
#define CHUNK 1024*100
1927
#define HEADER_SIZE 10
2028
#define FOOTER_SIZE 8
@@ -426,7 +434,8 @@ namespace node_compress_buffer {
426434
unsigned long tmpCrc = reverseBytes((unsigned char *) node::Buffer::Data(bufCrc));
427435
unsigned long tmpLen = meta->Get(ctx, Nan::New(SYM_LENGTH)).ToLocalChecked()->Uint32Value(ctx).FromJust();
428436

429-
crc = crc32_combine(crc, tmpCrc, tmpLen);
437+
crc = ZLIB_CRC32_COMBINE(crc, tmpCrc, tmpLen);
438+
430439
tot += tmpLen;
431440
}
432441

test/node-compress-buffer-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
util = require('util');
2-
fs = require('fs');
3-
crypto=require('crypto');
4-
compress = require('../index').compress;
5-
uncompress = require('../index').uncompress;
1+
const util = require('util');
2+
const fs = require('fs');
3+
const crypto = require('crypto');
4+
const compress = require('../index').compress;
5+
const uncompress = require('../index').uncompress;
66

77
function md5(data) {
88
var md5=crypto.createHash('md5');

0 commit comments

Comments
 (0)