Skip to content

Commit 7ce1dde

Browse files
committed
small refactorings
1 parent 1b9ccf9 commit 7ce1dde

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

lib/client.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ p.connect = function() {
5858

5959
con.on('readyForQuery', function() {
6060
self.readyForQuery = true;
61-
6261
self.pulseQueryQueue();
6362
});
6463

@@ -189,31 +188,23 @@ p.prepare = function(connection) {
189188

190189
};
191190

191+
var noParse = function(val) {
192+
return val;
193+
};
192194

193195
p.onRowDescription = function(msg) {
194-
var typeIds = msg.fields.map(function(field) {
195-
return field.dataTypeID;
196-
});
197-
var noParse = function(val) {
198-
return val;
199-
};
200-
201-
this.converters = typeIds.map(function(typeId) {
202-
return Client.dataTypeParser[typeId] || noParse;
196+
this.converters = msg.fields.map(function(field) {
197+
return Client.dataTypeParser[field.dataTypeID] || noParse;
203198
});
204199
};
205200

206201
//handles the raw 'dataRow' event from the connection does type coercion
207202
p.onDataRow = function(msg) {
208-
var fields = msg.fields;
209-
var converters = this.converters || [];
210-
var len = msg.fields.length;
211-
for(var i = 0; i < len; i++) {
212-
if(fields[i] !== null) {
213-
fields[i] = this.converters[i] (fields[i]);
203+
for(var i = 0; i < msg.fields.length; i++) {
204+
if(msg.fields[i] !== null) {
205+
msg.fields[i] = this.converters[i](msg.fields[i]);
214206
}
215207
}
216-
msg.fields = fields;
217208
this.emit('row', msg);
218209
};
219210

0 commit comments

Comments
 (0)