@@ -55,19 +55,13 @@ ReplyParser.prototype._parseResult = function (type) {
5555 }
5656
5757 if ( type === 45 ) {
58- var result = this . _buffer . toString ( this . _encoding , start , end ) ;
59- return new Error ( result ) ;
60- }
61-
62- if ( this . options . return_buffers ) {
58+ return new Error ( this . _buffer . toString ( this . _encoding , start , end ) ) ;
59+ } else if ( this . options . return_buffers ) {
6360 return this . _buffer . slice ( start , end ) ;
64- } else {
65- if ( end - start < 65536 ) { // completely arbitrary
66- return small_toString ( this . _buffer , start , end ) ;
67- } else {
68- return this . _buffer . toString ( this . _encoding , start , end ) ;
69- }
61+ } else if ( end - start < 65536 ) { // completely arbitrary
62+ return small_toString ( this . _buffer , start , end ) ;
7063 }
64+ return this . _buffer . toString ( this . _encoding , start , end ) ;
7165 } else if ( type === 58 ) { // :
7266 // up to the delimiter
7367 end = this . _packetEndOffset ( ) - 1 ;
@@ -92,7 +86,7 @@ ReplyParser.prototype._parseResult = function (type) {
9286
9387 // packets with a size of -1 are considered null
9488 if ( packetHeader . size === - 1 ) {
95- return undefined ;
89+ return null ;
9690 }
9791
9892 end = this . _offset + packetHeader . size ;
@@ -108,10 +102,9 @@ ReplyParser.prototype._parseResult = function (type) {
108102
109103 if ( this . options . return_buffers ) {
110104 return this . _buffer . slice ( start , end ) ;
111- } else {
112- return this . _buffer . toString ( this . _encoding , start , end ) ;
113105 }
114- } else if ( type === 42 ) { // *
106+ return this . _buffer . toString ( this . _encoding , start , end ) ;
107+ } else { // *
115108 offset = this . _offset ;
116109 packetHeader = new Packet ( type , this . parseHeader ( ) ) ;
117110
@@ -136,9 +129,6 @@ ReplyParser.prototype._parseResult = function (type) {
136129 throw new IncompleteReadBuffer ( "Wait for more data." ) ;
137130 }
138131 res = this . _parseResult ( ntype ) ;
139- if ( res === undefined ) {
140- res = null ;
141- }
142132 reply . push ( res ) ;
143133 }
144134
@@ -176,18 +166,8 @@ ReplyParser.prototype.execute = function (buffer) {
176166 } else if ( type === 36 ) { // $
177167 ret = this . _parseResult ( type ) ;
178168
179- if ( ret === null ) {
180- break ;
181- }
182-
183- // check the state for what is the result of
184- // a -1, set it back up for a null reply
185- if ( ret === undefined ) {
186- ret = null ;
187- }
188-
189169 this . send_reply ( ret ) ;
190- } else if ( type === 42 ) { // *
170+ } else if ( type === 42 ) { // 42 *
191171 // set a rewind point. if a failure occurs,
192172 // wait for the next execute()/append() and try again
193173 offset = this . _offset - 1 ;
@@ -199,9 +179,6 @@ ReplyParser.prototype.execute = function (buffer) {
199179 } catch ( err ) {
200180 // catch the error (not enough data), rewind, and wait
201181 // for the next packet to appear
202- if ( ! ( err instanceof IncompleteReadBuffer ) ) {
203- throw err ;
204- }
205182 this . _offset = offset ;
206183 break ;
207184 }
0 commit comments