@@ -474,7 +474,7 @@ Connection.prototype.parseT = function(msg) {
474
474
msg . fieldCount = this . parseInt16 ( ) ;
475
475
var fields = [ ] ;
476
476
for ( var i = 0 ; i < msg . fieldCount ; i ++ ) {
477
- fields [ i ] = this . parseField ( ) ;
477
+ fields . push ( this . parseField ( ) ) ;
478
478
}
479
479
msg . fields = fields ;
480
480
return msg ;
@@ -498,7 +498,11 @@ Connection.prototype.parseD = function(msg) {
498
498
var fields = [ ] ;
499
499
for ( var i = 0 ; i < fieldCount ; i ++ ) {
500
500
var length = this . parseInt32 ( ) ;
501
- fields [ i ] = ( length === - 1 ? null : this . readBytes ( length ) ) ;
501
+ var value = null ;
502
+ if ( length !== - 1 ) {
503
+ value = this . readBytes ( length ) ;
504
+ }
505
+ fields . push ( value ) ;
502
506
}
503
507
msg . fieldCount = fieldCount ;
504
508
msg . fields = fields ;
@@ -553,49 +557,35 @@ Connection.prototype.parseA = function(msg) {
553
557
} ;
554
558
555
559
Connection . prototype . parseGH = function ( msg ) {
556
- msg . binary = Boolean ( this . parseInt8 ( ) ) ;
560
+ var isBinary = this . buffer [ this . offset ] !== 0 ;
561
+ this . offset ++ ;
562
+ msg . binary = isBinary ;
557
563
var columnCount = this . parseInt16 ( ) ;
558
564
msg . columnTypes = [ ] ;
559
565
for ( var i = 0 ; i < columnCount ; i ++ ) {
560
- msg . columnTypes [ i ] = this . parseInt16 ( ) ;
566
+ msg . columnTypes . push ( this . parseInt16 ( ) ) ;
561
567
}
562
568
return msg ;
563
569
} ;
564
570
565
- Connection . prototype . parseInt8 = function ( ) {
566
- var value = Number ( this . buffer [ this . offset ] ) ;
567
- this . offset ++ ;
568
- return value ;
569
- } ;
570
-
571
571
Connection . prototype . readChar = function ( ) {
572
572
return Buffer ( [ this . buffer [ this . offset ++ ] ] ) . toString ( this . encoding ) ;
573
573
} ;
574
574
575
575
Connection . prototype . parseInt32 = function ( ) {
576
- var value = this . peekInt32 ( ) ;
576
+ var value = this . buffer . readInt32BE ( this . offset , true ) ;
577
577
this . offset += 4 ;
578
578
return value ;
579
579
} ;
580
580
581
- Connection . prototype . peekInt32 = function ( offset ) {
582
- offset = offset || this . offset ;
583
- var buffer = this . buffer ;
584
- return ( ( buffer [ offset ++ ] << 24 ) +
585
- ( buffer [ offset ++ ] << 16 ) +
586
- ( buffer [ offset ++ ] << 8 ) +
587
- buffer [ offset ++ ] ) ;
588
- } ;
589
-
590
-
591
581
Connection . prototype . parseInt16 = function ( ) {
592
- return ( ( this . buffer [ this . offset ++ ] << 8 ) +
593
- ( this . buffer [ this . offset ++ ] << 0 ) ) ;
582
+ var value = this . buffer . readInt16BE ( this . offset , true ) ;
583
+ this . offset += 2 ;
584
+ return value ;
594
585
} ;
595
586
596
587
Connection . prototype . readString = function ( length ) {
597
- return this . buffer . toString ( this . encoding , this . offset ,
598
- ( this . offset += length ) ) ;
588
+ return this . buffer . toString ( this . encoding , this . offset , ( this . offset += length ) ) ;
599
589
} ;
600
590
601
591
Connection . prototype . readBytes = function ( length ) {
0 commit comments