fix jshint errors for lib/connection.js

This commit is contained in:
Philipp Borgers 2013-01-21 14:29:31 +01:00
parent 74c8945cfe
commit cedcf0ca35

View File

@ -80,10 +80,11 @@ p.attachListeners = function(stream) {
var self = this;
stream.on('data', function(buffer) {
self.setBuffer(buffer);
var msg;
while(msg = self.parseMessage()) {
var msg = self.parseMessage();
while(msg) {
self.emit('message', msg);
self.emit(msg.name, msg);
msg = self.parseMessage();
}
});
};
@ -102,7 +103,7 @@ p.requestSsl = function(config) {
.add(bodyBuffer)
.join();
this.stream.write(buffer);
}
};
p.startup = function(config) {
var bodyBuffer = this.writer
@ -147,13 +148,13 @@ p.password = function(password) {
};
p._send = function(code, more) {
if(!this.stream.writable) return false;
if(!this.stream.writable) { return false; }
if(more === true) {
this.writer.addHeader(code);
} else {
return this.stream.write(this.writer.flush(code));
}
}
};
p.query = function(text) {
//0x51 = Q
@ -239,13 +240,13 @@ var emptyBuffer = Buffer(0);
p.flush = function() {
//0x48 = 'H'
this.writer.add(emptyBuffer)
this.writer.add(emptyBuffer);
this._send(0x48);
}
};
p.sync = function() {
//clear out any pending data in the writer
this.writer.flush(0)
this.writer.flush(0);
this.writer.add(emptyBuffer);
this._send(0x53);
@ -263,15 +264,15 @@ p.describe = function(msg, more) {
};
p.sendCopyFromChunk = function (chunk) {
this.stream.write(this.writer.add(chunk).flush(0x64));
}
};
p.endCopyFrom = function () {
this.stream.write(this.writer.add(emptyBuffer).flush(0x63));
}
};
p.sendCopyFail = function (msg) {
//this.stream.write(this.writer.add(emptyBuffer).flush(0x66));
this.writer.addCString(msg);
this._send(0x66);
}
};
//parsing methods
p.setBuffer = function(buffer) {
if(this.lastBuffer) { //we have unfinished biznaz
@ -476,8 +477,8 @@ p.parseD = function(msg) {
var fields = [];
for(var i = 0; i < fieldCount; i++) {
var length = this.parseInt32();
fields[i] = (length === -1 ? null : this.readBytes(length))
};
fields[i] = (length === -1 ? null : this.readBytes(length));
}
msg.fieldCount = fieldCount;
msg.fields = fields;
return msg;
@ -542,7 +543,7 @@ p.parseInt8 = function () {
var value = Number(this.buffer[this.offset]);
this.offset++;
return value;
}
};
p.readChar = function() {
return Buffer([this.buffer[this.offset++]]).toString(this.encoding);
};
@ -578,13 +579,13 @@ p.readBytes = function(length) {
p.parseCString = function() {
var start = this.offset;
while(this.buffer[this.offset++]) { };
while(this.buffer[this.offset++]) { }
return this.buffer.toString(this.encoding, start, this.offset - 1);
};
p.parsed = function (msg) {
//exclude length field
msg.chunk = this.readBytes(msg.length - 4);
return msg;
}
};
//end parsing methods
module.exports = Connection;