From d55dbe70d5023c9a5af5fa0af50d940428b8dc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 7 Nov 2018 15:06:38 +0100 Subject: [PATCH] Do not use deprecated Buffer constructor --- index.js | 6 +++--- test/copy-from.js | 4 ++-- test/copy-to.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index c1b23f1..a170c72 100644 --- a/index.js +++ b/index.js @@ -30,11 +30,11 @@ CopyStreamQuery.prototype.submit = function(connection) { } -var copyDataBuffer = Buffer([code.CopyData]) +var copyDataBuffer = Buffer.from([code.CopyData]) CopyStreamQuery.prototype._transform = function(chunk, enc, cb) { var Int32Len = 4; this.push(copyDataBuffer) - var lenBuffer = Buffer(Int32Len) + var lenBuffer = Buffer.alloc(Int32Len) lenBuffer.writeUInt32BE(chunk.length + Int32Len, 0) this.push(lenBuffer) this.push(chunk) @@ -43,7 +43,7 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) { CopyStreamQuery.prototype._flush = function(cb) { var Int32Len = 4; - var finBuffer = Buffer([code.CopyDone, 0, 0, 0, Int32Len]) + var finBuffer = Buffer.from([code.CopyDone, 0, 0, 0, Int32Len]) this.push(finBuffer) this.cb_flush = cb } diff --git a/test/copy-from.js b/test/copy-from.js index ee98a11..d42216b 100644 --- a/test/copy-from.js +++ b/test/copy-from.js @@ -33,7 +33,7 @@ var testRange = function(top) { var txt = 'COPY numbers FROM STDIN' var stream = fromClient.query(copy(txt)) for(var i = 0; i < top; i++) { - stream.write(Buffer('' + i + '\t' + i*10 + '\n')) + stream.write(Buffer.from('' + i + '\t' + i*10 + '\n')) } stream.end() var countDone = gonna('have correct count') @@ -69,7 +69,7 @@ var testSingleEnd = function() { assert(count==1, '`end` Event was triggered ' + count + ' times'); if (count == 1) fromClient.end(); }) - stream.end(Buffer('1\n')) + stream.end(Buffer.from('1\n')) } testSingleEnd() diff --git a/test/copy-to.js b/test/copy-to.js index 9e88e71..7755453 100644 --- a/test/copy-to.js +++ b/test/copy-to.js @@ -31,7 +31,7 @@ var testComparators = function() { assert(copy1._gotCopyOutResponse, 'should have received CopyOutResponse') assert(!copy1._remainder, 'Message with no additional data (len=Int4Len+0) should not leave a remainder') })) - copy1.end(new Buffer([code.CopyOutResponse, 0x00, 0x00, 0x00, 0x04])); + copy1.end(Buffer.from([code.CopyOutResponse, 0x00, 0x00, 0x00, 0x04])); }