diff --git a/lib/connection.js b/lib/connection.js index 6584c871d..8ca279dd4 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -296,7 +296,7 @@ Connection.prototype.execute = function(config, more) { this._send(0x45, more); }; -var emptyBuffer = Buffer(0); +var emptyBuffer = new Buffer(0); Connection.prototype.flush = function() { //0x48 = 'H' diff --git a/test/buffer-list.js b/test/buffer-list.js index 3aa245521..6ee22ab7f 100644 --- a/test/buffer-list.js +++ b/test/buffer-list.js @@ -9,7 +9,7 @@ p.add = function(buffer, front) { }; p.addInt16 = function(val, front) { - return this.add(Buffer([(val >>> 8),(val >>> 0)]),front); + return this.add(new Buffer([(val >>> 8), (val >>> 0)]), front); }; p.getByteLength = function(initial) { @@ -19,7 +19,7 @@ p.getByteLength = function(initial) { }; p.addInt32 = function(val, first) { - return this.add(Buffer([ + return this.add(new Buffer([ (val >>> 24 & 0xFF), (val >>> 16 & 0xFF), (val >>> 8 & 0xFF), @@ -36,7 +36,7 @@ p.addCString = function(val, front) { }; p.addChar = function(char, first) { - return this.add(Buffer(char,'utf8'), first); + return this.add(new Buffer(char, 'utf8'), first); }; p.join = function(appendLength, char) { @@ -49,7 +49,7 @@ p.join = function(appendLength, char) { this.addChar(char, true); length++; } - var result = Buffer(length); + var result = new Buffer(length); var index = 0; this.buffers.forEach(function(buffer) { buffer.copy(result, index, 0); diff --git a/test/test-buffers.js b/test/test-buffers.js index ddb6ba637..bb29453a9 100644 --- a/test/test-buffers.js +++ b/test/test-buffers.js @@ -4,7 +4,7 @@ require(__dirname+'/test-helper'); var buffers = {}; buffers.readyForQuery = function() { return new BufferList() - .add(Buffer('I')) + .add(new Buffer('I')) .join(true,'Z'); }; @@ -23,7 +23,7 @@ buffers.authenticationCleartextPassword = function() { buffers.authenticationMD5Password = function() { return new BufferList() .addInt32(5) - .add(Buffer([1,2,3,4])) + .add(new Buffer([1, 2, 3, 4])) .join(true, 'R'); }; @@ -94,7 +94,7 @@ var errorOrNotice = function(fields) { buf.addChar(field.type); buf.addCString(field.value); }); - return buf.add(Buffer([0]));//terminator + return buf.add(new Buffer([0]));//terminator } buffers.parseComplete = function() { diff --git a/test/unit/client/md5-password-tests.js b/test/unit/client/md5-password-tests.js index bd5ca46f0..a04a4280f 100644 --- a/test/unit/client/md5-password-tests.js +++ b/test/unit/client/md5-password-tests.js @@ -3,7 +3,7 @@ require(__dirname + '/test-helper'); test('md5 authentication', function() { var client = createClient(); client.password = "!"; - var salt = Buffer([1, 2, 3, 4]); + var salt = new Buffer([1, 2, 3, 4]); client.connection.emit('authenticationMD5Password', {salt: salt}); test('responds', function() { diff --git a/test/unit/connection/inbound-parser-tests.js b/test/unit/connection/inbound-parser-tests.js index 55d71d579..c951283bb 100644 --- a/test/unit/connection/inbound-parser-tests.js +++ b/test/unit/connection/inbound-parser-tests.js @@ -159,7 +159,7 @@ test('Connection', function() { testForMessage(plainPasswordBuffer, expectedPlainPasswordMessage); var msg = testForMessage(md5PasswordBuffer, expectedMD5PasswordMessage); test('md5 has right salt', function() { - assert.equalBuffers(msg.salt, Buffer([1,2,3,4])); + assert.equalBuffers(msg.salt, new Buffer([1, 2, 3, 4])); }); testForMessage(paramStatusBuffer, expectedParameterStatusMessage); testForMessage(backendKeyDataBuffer, expectedBackendKeyDataMessage); @@ -174,7 +174,7 @@ test('Connection', function() { }); test("no data message", function() { - testForMessage(Buffer([0x6e, 0, 0, 0, 4]), { + testForMessage(new Buffer([0x6e, 0, 0, 0, 4]), { name: 'noData' }); }); diff --git a/test/unit/connection/outbound-sending-tests.js b/test/unit/connection/outbound-sending-tests.js index 3dde8a3cb..0fc77edad 100644 --- a/test/unit/connection/outbound-sending-tests.js +++ b/test/unit/connection/outbound-sending-tests.js @@ -104,12 +104,12 @@ test('bind messages', function() { .addInt16(0) .addInt16(4) .addInt32(1) - .add(Buffer("1")) + .add(new Buffer("1")) .addInt32(2) - .add(Buffer("hi")) + .add(new Buffer("hi")) .addInt32(-1) .addInt32(4) - .add(Buffer('zing')) + .add(new Buffer('zing')) .addInt16(0) .join(true, 'B'); assert.received(stream, expectedBuffer); @@ -132,9 +132,9 @@ test('with named statement, portal, and buffer value', function() { .addInt16(1)//binary .addInt16(4) .addInt32(1) - .add(Buffer("1")) + .add(new Buffer("1")) .addInt32(2) - .add(Buffer("hi")) + .add(new Buffer("hi")) .addInt32(-1) .addInt32(4) .add(new Buffer('zing', 'UTF-8'))