From 7ce1ddeab5d808a37643b8de692775d263c191e5 Mon Sep 17 00:00:00 2001 From: brianc Date: Tue, 2 Nov 2010 23:46:13 -0500 Subject: [PATCH] small refactorings --- lib/client.js | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/client.js b/lib/client.js index da3924d5..df3f1f1d 100644 --- a/lib/client.js +++ b/lib/client.js @@ -58,7 +58,6 @@ p.connect = function() { con.on('readyForQuery', function() { self.readyForQuery = true; - self.pulseQueryQueue(); }); @@ -189,31 +188,23 @@ p.prepare = function(connection) { }; +var noParse = function(val) { + return val; +}; p.onRowDescription = function(msg) { - var typeIds = msg.fields.map(function(field) { - return field.dataTypeID; - }); - var noParse = function(val) { - return val; - }; - - this.converters = typeIds.map(function(typeId) { - return Client.dataTypeParser[typeId] || noParse; + this.converters = msg.fields.map(function(field) { + return Client.dataTypeParser[field.dataTypeID] || noParse; }); }; //handles the raw 'dataRow' event from the connection does type coercion p.onDataRow = function(msg) { - var fields = msg.fields; - var converters = this.converters || []; - var len = msg.fields.length; - for(var i = 0; i < len; i++) { - if(fields[i] !== null) { - fields[i] = this.converters[i] (fields[i]); + for(var i = 0; i < msg.fields.length; i++) { + if(msg.fields[i] !== null) { + msg.fields[i] = this.converters[i](msg.fields[i]); } } - msg.fields = fields; this.emit('row', msg); };