@@ -80,10 +80,11 @@ p.attachListeners = function(stream) {
80
80
var self = this ;
81
81
stream . on ( 'data' , function ( buffer ) {
82
82
self . setBuffer ( buffer ) ;
83
- var msg ;
84
- while ( msg = self . parseMessage ( ) ) {
83
+ var msg = self . parseMessage ( ) ;
84
+ while ( msg ) {
85
85
self . emit ( 'message' , msg ) ;
86
86
self . emit ( msg . name , msg ) ;
87
+ msg = self . parseMessage ( ) ;
87
88
}
88
89
} ) ;
89
90
} ;
@@ -102,7 +103,7 @@ p.requestSsl = function(config) {
102
103
. add ( bodyBuffer )
103
104
. join ( ) ;
104
105
this . stream . write ( buffer ) ;
105
- }
106
+ } ;
106
107
107
108
p . startup = function ( config ) {
108
109
var bodyBuffer = this . writer
@@ -147,13 +148,13 @@ p.password = function(password) {
147
148
} ;
148
149
149
150
p . _send = function ( code , more ) {
150
- if ( ! this . stream . writable ) return false ;
151
+ if ( ! this . stream . writable ) { return false ; }
151
152
if ( more === true ) {
152
153
this . writer . addHeader ( code ) ;
153
154
} else {
154
155
return this . stream . write ( this . writer . flush ( code ) ) ;
155
156
}
156
- }
157
+ } ;
157
158
158
159
p . query = function ( text ) {
159
160
//0x51 = Q
@@ -239,13 +240,13 @@ var emptyBuffer = Buffer(0);
239
240
240
241
p . flush = function ( ) {
241
242
//0x48 = 'H'
242
- this . writer . add ( emptyBuffer )
243
+ this . writer . add ( emptyBuffer ) ;
243
244
this . _send ( 0x48 ) ;
244
- }
245
+ } ;
245
246
246
247
p . sync = function ( ) {
247
248
//clear out any pending data in the writer
248
- this . writer . flush ( 0 )
249
+ this . writer . flush ( 0 ) ;
249
250
250
251
this . writer . add ( emptyBuffer ) ;
251
252
this . _send ( 0x53 ) ;
@@ -263,15 +264,15 @@ p.describe = function(msg, more) {
263
264
} ;
264
265
p . sendCopyFromChunk = function ( chunk ) {
265
266
this . stream . write ( this . writer . add ( chunk ) . flush ( 0x64 ) ) ;
266
- }
267
+ } ;
267
268
p . endCopyFrom = function ( ) {
268
269
this . stream . write ( this . writer . add ( emptyBuffer ) . flush ( 0x63 ) ) ;
269
- }
270
+ } ;
270
271
p . sendCopyFail = function ( msg ) {
271
272
//this.stream.write(this.writer.add(emptyBuffer).flush(0x66));
272
273
this . writer . addCString ( msg ) ;
273
274
this . _send ( 0x66 ) ;
274
- }
275
+ } ;
275
276
//parsing methods
276
277
p . setBuffer = function ( buffer ) {
277
278
if ( this . lastBuffer ) { //we have unfinished biznaz
@@ -476,8 +477,8 @@ p.parseD = function(msg) {
476
477
var fields = [ ] ;
477
478
for ( var i = 0 ; i < fieldCount ; i ++ ) {
478
479
var length = this . parseInt32 ( ) ;
479
- fields [ i ] = ( length === - 1 ? null : this . readBytes ( length ) )
480
- } ;
480
+ fields [ i ] = ( length === - 1 ? null : this . readBytes ( length ) ) ;
481
+ }
481
482
msg . fieldCount = fieldCount ;
482
483
msg . fields = fields ;
483
484
return msg ;
@@ -542,7 +543,7 @@ p.parseInt8 = function () {
542
543
var value = Number ( this . buffer [ this . offset ] ) ;
543
544
this . offset ++ ;
544
545
return value ;
545
- }
546
+ } ;
546
547
p . readChar = function ( ) {
547
548
return Buffer ( [ this . buffer [ this . offset ++ ] ] ) . toString ( this . encoding ) ;
548
549
} ;
@@ -578,13 +579,13 @@ p.readBytes = function(length) {
578
579
579
580
p . parseCString = function ( ) {
580
581
var start = this . offset ;
581
- while ( this . buffer [ this . offset ++ ] ) { } ;
582
+ while ( this . buffer [ this . offset ++ ] ) { }
582
583
return this . buffer . toString ( this . encoding , start , this . offset - 1 ) ;
583
584
} ;
584
585
p . parsed = function ( msg ) {
585
586
//exclude length field
586
587
msg . chunk = this . readBytes ( msg . length - 4 ) ;
587
588
return msg ;
588
- }
589
+ } ;
589
590
//end parsing methods
590
591
module . exports = Connection ;
0 commit comments