Skip to content

Commit

Permalink
fixed Buffer constructor deprecation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dehmer committed Mar 25, 2021
1 parent b85b7b9 commit 226d988
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/binarywriter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = BinaryWriter;

function BinaryWriter(size, allowResize) {
this.buffer = new Buffer(size);
this.buffer = new Buffer.alloc(size);
this.position = 0;
this.allowResize = allowResize;
}
Expand Down Expand Up @@ -54,7 +54,7 @@ BinaryWriter.prototype.writeVarInt = function (value) {
BinaryWriter.prototype.ensureSize = function (size) {
if (this.buffer.length < this.position + size) {
if (this.allowResize) {
var tempBuffer = new Buffer(this.position + size);
var tempBuffer = new Buffer.alloc(this.position + size);
this.buffer.copy(tempBuffer, 0, 0, this.buffer.length);
this.buffer = tempBuffer;
}
Expand Down

0 comments on commit 226d988

Please sign in to comment.