@@ -55,19 +55,13 @@ ReplyParser.prototype._parseResult = function (type) {
55
55
}
56
56
57
57
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 ) {
63
60
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 ) ;
70
63
}
64
+ return this . _buffer . toString ( this . _encoding , start , end ) ;
71
65
} else if ( type === 58 ) { // :
72
66
// up to the delimiter
73
67
end = this . _packetEndOffset ( ) - 1 ;
@@ -92,7 +86,7 @@ ReplyParser.prototype._parseResult = function (type) {
92
86
93
87
// packets with a size of -1 are considered null
94
88
if ( packetHeader . size === - 1 ) {
95
- return undefined ;
89
+ return null ;
96
90
}
97
91
98
92
end = this . _offset + packetHeader . size ;
@@ -108,10 +102,9 @@ ReplyParser.prototype._parseResult = function (type) {
108
102
109
103
if ( this . options . return_buffers ) {
110
104
return this . _buffer . slice ( start , end ) ;
111
- } else {
112
- return this . _buffer . toString ( this . _encoding , start , end ) ;
113
105
}
114
- } else if ( type === 42 ) { // *
106
+ return this . _buffer . toString ( this . _encoding , start , end ) ;
107
+ } else { // *
115
108
offset = this . _offset ;
116
109
packetHeader = new Packet ( type , this . parseHeader ( ) ) ;
117
110
@@ -136,9 +129,6 @@ ReplyParser.prototype._parseResult = function (type) {
136
129
throw new IncompleteReadBuffer ( "Wait for more data." ) ;
137
130
}
138
131
res = this . _parseResult ( ntype ) ;
139
- if ( res === undefined ) {
140
- res = null ;
141
- }
142
132
reply . push ( res ) ;
143
133
}
144
134
@@ -176,18 +166,8 @@ ReplyParser.prototype.execute = function (buffer) {
176
166
} else if ( type === 36 ) { // $
177
167
ret = this . _parseResult ( type ) ;
178
168
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
-
189
169
this . send_reply ( ret ) ;
190
- } else if ( type === 42 ) { // *
170
+ } else if ( type === 42 ) { // 42 *
191
171
// set a rewind point. if a failure occurs,
192
172
// wait for the next execute()/append() and try again
193
173
offset = this . _offset - 1 ;
@@ -199,9 +179,6 @@ ReplyParser.prototype.execute = function (buffer) {
199
179
} catch ( err ) {
200
180
// catch the error (not enough data), rewind, and wait
201
181
// for the next packet to appear
202
- if ( ! ( err instanceof IncompleteReadBuffer ) ) {
203
- throw err ;
204
- }
205
182
this . _offset = offset ;
206
183
break ;
207
184
}
0 commit comments