mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
removed switch statement
This commit is contained in:
parent
a45ee945d3
commit
32d6fd4115
45
lib/index.js
45
lib/index.js
@ -139,29 +139,11 @@ p.parseMessage = function() {
|
||||
return false;
|
||||
}
|
||||
var messageID = this.buffer[this.offset];
|
||||
switch(messageID) {
|
||||
case UTF8.R:
|
||||
return this.parseR();
|
||||
case UTF8.S:
|
||||
return this.parseS();
|
||||
case UTF8.K:
|
||||
return this.parseK();
|
||||
case UTF8.Z:
|
||||
return this.parseZ();
|
||||
case UTF8.C:
|
||||
return this.parseC();
|
||||
case UTF8.T:
|
||||
return this.parseT();
|
||||
case UTF8.D:
|
||||
return this.parseD();
|
||||
case UTF8.E:
|
||||
return this.parseE();
|
||||
default:
|
||||
throw new Error("Unsupported message ID: " + Buffer([messageID]).toString('utf8') + " (" + messageID.toString(16) + ")");
|
||||
}
|
||||
return this["parse"+messageID]();
|
||||
};
|
||||
|
||||
p.parseR = function() {
|
||||
//parse 'R' message
|
||||
p.parse82 = function() {
|
||||
var type = this.buffer[this.offset++];
|
||||
var length = this.parseLength();
|
||||
if(length == 8) {
|
||||
@ -175,21 +157,24 @@ p.parseR = function() {
|
||||
throw new Error("Unknown AuthenticatinOk message type");
|
||||
};
|
||||
|
||||
p.parseS = function(buffer) {
|
||||
//parse 'S' message
|
||||
p.parse83 = function(buffer) {
|
||||
var msg = this.parseStart('ParameterStatus');
|
||||
msg.parameterName = this.parseCString();
|
||||
msg.parameterValue = this.parseCString();
|
||||
return msg;
|
||||
};
|
||||
|
||||
p.parseK = function() {
|
||||
//parse 'K' message
|
||||
p.parse75 = function() {
|
||||
var msg = this.parseStart('BackendKeyData');
|
||||
msg.processID = this.readInt32();
|
||||
msg.secretKey = this.readInt32();
|
||||
return msg;
|
||||
};
|
||||
|
||||
p.parseC = function() {
|
||||
//parse 'C' message
|
||||
p.parse67 = function() {
|
||||
var msg = this.parseStart('CommandComplete');
|
||||
msg.text = this.parseCString();
|
||||
return msg;
|
||||
@ -208,13 +193,15 @@ p.readChar = function() {
|
||||
return Buffer([this.buffer[this.offset++]]).toString('utf8');
|
||||
};
|
||||
|
||||
p.parseZ = function() {
|
||||
//parse 'Z' message
|
||||
p.parse90 = function() {
|
||||
var msg = this.parseStart('ReadyForQuery');
|
||||
msg.status = this.readChar();
|
||||
return msg;
|
||||
};
|
||||
|
||||
p.parseT = function() {
|
||||
//parse 'T' message
|
||||
p.parse84 = function() {
|
||||
var msg = this.parseStart('RowDescription');
|
||||
msg.fieldCount = this.readInt16();
|
||||
var fields = [];
|
||||
@ -238,7 +225,8 @@ p.parseField = function() {
|
||||
return row;
|
||||
};
|
||||
|
||||
p.parseD = function() {
|
||||
//parse 'D' message
|
||||
p.parse68 = function() {
|
||||
var msg = this.parseStart('DataRow');
|
||||
var fieldCount = this.readInt16();
|
||||
var fields = [];
|
||||
@ -250,7 +238,8 @@ p.parseD = function() {
|
||||
return msg;
|
||||
};
|
||||
|
||||
p.parseE = function() {
|
||||
//parse 'E' message
|
||||
p.parse69 = function() {
|
||||
var msg = this.parseStart('Error');
|
||||
var fields = {};
|
||||
var fieldType = this.readString(1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user