Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new with Buffer everywhere #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 4 additions & 4 deletions test/buffer-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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),
Expand All @@ -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) {
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions test/test-buffers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};

Expand All @@ -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');
};

Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/client/md5-password-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/connection/inbound-parser-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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'
});
});
Expand Down
10 changes: 5 additions & 5 deletions test/unit/connection/outbound-sending-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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'))
Expand Down