File tree Expand file tree Collapse file tree 2 files changed +16
-21
lines changed Expand file tree Collapse file tree 2 files changed +16
-21
lines changed Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ RedisClient.prototype.init_parser = function () {
293
293
294
294
// return_buffers sends back Buffers from parser to callback. detect_buffers sends back Buffers from parser, but
295
295
// converts to Strings if the input arguments are not Buffers.
296
- this . reply_parser = new this . parser_module . Parser ( self . options . return_buffers || self . options . detect_buffers || false ) ;
296
+ this . reply_parser = new this . parser_module . Parser ( self . options . return_buffers || self . options . detect_buffers ) ;
297
297
// Important: Only send results / errors async.
298
298
// That way the result / error won't stay in a try catch block and catch user things
299
299
this . reply_parser . send_error = function ( data ) {
Original file line number Diff line number Diff line change @@ -4,37 +4,32 @@ var hiredis = require('hiredis');
4
4
5
5
function HiredisReplyParser ( return_buffers ) {
6
6
this . name = exports . name ;
7
- this . return_buffers = return_buffers ;
8
- this . reset ( ) ;
9
- }
10
-
11
- HiredisReplyParser . prototype . reset = function ( ) {
12
7
this . reader = new hiredis . Reader ( {
13
- return_buffers : this . return_buffers || false
8
+ return_buffers : return_buffers
14
9
} ) ;
10
+ }
11
+
12
+ HiredisReplyParser . prototype . return_data = function ( ) {
13
+ try {
14
+ return this . reader . get ( ) ;
15
+ } catch ( err ) {
16
+ // Protocol errors land here
17
+ this . send_error ( err ) ;
18
+ return void 0 ;
19
+ }
15
20
} ;
16
21
17
22
HiredisReplyParser . prototype . execute = function ( data ) {
18
- var reply ;
19
23
this . reader . feed ( data ) ;
20
- while ( true ) {
21
- try {
22
- reply = this . reader . get ( ) ;
23
- } catch ( err ) {
24
- // Protocol errors land here
25
- this . send_error ( err ) ;
26
- break ;
27
- }
28
-
29
- if ( reply === undefined ) {
30
- break ;
31
- }
24
+ var reply = this . return_data ( ) ;
32
25
33
- if ( reply && reply . constructor === Error ) {
26
+ while ( reply !== undefined ) {
27
+ if ( reply && reply . name === 'Error' ) {
34
28
this . send_error ( reply ) ;
35
29
} else {
36
30
this . send_reply ( reply ) ;
37
31
}
32
+ reply = this . return_data ( ) ;
38
33
}
39
34
} ;
40
35
You can’t perform that action at this time.
0 commit comments