Skip to content

Commit f3eae3c

Browse files
authored
Merge pull request #8 from lpinca/fix/deprecation-warning
Do not use the deprecated Buffer() constructor
2 parents 3d365ba + 52c7f32 commit f3eae3c

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

lib/crc32-stream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var crc32 = require('crc').crc32;
1212

1313
var CRC32Stream = module.exports = function CRC32Stream(options) {
1414
Transform.call(this, options);
15-
this.checksum = new Buffer(4);
15+
this.checksum = Buffer.allocUnsafe(4);
1616
this.checksum.writeInt32BE(0, 0);
1717

1818
this.rawSize = 0;
@@ -30,7 +30,7 @@ CRC32Stream.prototype._transform = function(chunk, encoding, callback) {
3030
};
3131

3232
CRC32Stream.prototype.digest = function(encoding) {
33-
var checksum = new Buffer(4);
33+
var checksum = Buffer.allocUnsafe(4);
3434
checksum.writeUInt32BE(this.checksum >>> 0, 0);
3535
return encoding ? checksum.toString(encoding) : checksum;
3636
};

lib/deflate-crc32-stream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var crc32 = require('crc').crc32;
1313
var DeflateCRC32Stream = module.exports = function (options) {
1414
zlib.DeflateRaw.call(this, options);
1515

16-
this.checksum = new Buffer(4);
16+
this.checksum = Buffer.allocUnsafe(4);
1717
this.checksum.writeInt32BE(0, 0);
1818

1919
this.rawSize = 0;
@@ -49,7 +49,7 @@ DeflateCRC32Stream.prototype.write = function(chunk, enc, cb) {
4949
};
5050

5151
DeflateCRC32Stream.prototype.digest = function(encoding) {
52-
var checksum = new Buffer(4);
52+
var checksum = Buffer.allocUnsafe(4);
5353
checksum.writeUInt32BE(this.checksum >>> 0, 0);
5454
return encoding ? checksum.toString(encoding) : checksum;
5555
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"lib"
2121
],
2222
"engines": {
23-
"node": ">= 4"
23+
"node": ">= 4.5.0"
2424
},
2525
"scripts": {
2626
"test": "mocha --reporter dot"

test/helpers/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function adjustDateByOffset(d, offset) {
2121
module.exports.adjustDateByOffset = adjustDateByOffset;
2222

2323
function binaryBuffer(n) {
24-
var buffer = new Buffer(n);
24+
var buffer = Buffer.allocUnsafe(n);
2525

2626
for (var i = 0; i < n; i++) {
2727
buffer.writeUInt8(i&255, i);
@@ -35,7 +35,7 @@ module.exports.binaryBuffer = binaryBuffer;
3535
function BinaryStream(size, options) {
3636
Readable.call(this, options);
3737

38-
var buf = new Buffer(size);
38+
var buf = Buffer.allocUnsafe(size);
3939

4040
for (var i = 0; i < size; i++) {
4141
buf.writeUInt8(i&255, i);

0 commit comments

Comments
 (0)