File tree Expand file tree Collapse file tree 4 files changed +7
-33
lines changed Expand file tree Collapse file tree 4 files changed +7
-33
lines changed Original file line number Diff line number Diff line change @@ -301,18 +301,8 @@ RedisClient.prototype.init_parser = function () {
301
301
this . reply_parser = new this . parser_module . Parser ( {
302
302
return_buffers : self . options . return_buffers || self . options . detect_buffers || false
303
303
} ) ;
304
-
305
- // "reply error" is an error sent back by Redis
306
- this . reply_parser . on ( "reply error" , function ( reply ) {
307
- self . return_error ( reply ) ;
308
- } ) ;
309
- this . reply_parser . on ( "reply" , function ( reply ) {
310
- self . return_reply ( reply ) ;
311
- } ) ;
312
- // "error" is bad. Somehow the parser got confused. It'll try to reset and continue.
313
- this . reply_parser . on ( "error" , function ( err ) {
314
- self . emit ( "error" , new Error ( "Redis reply parser error: " + err . stack ) ) ;
315
- } ) ;
304
+ this . reply_parser . send_error = this . return_error . bind ( self ) ;
305
+ this . reply_parser . send_reply = this . return_reply . bind ( self ) ;
316
306
} ;
317
307
318
308
RedisClient . prototype . on_ready = function ( ) {
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- var events = require ( "events" ) ,
4
- util = require ( "util" ) ,
5
- hiredis = require ( "hiredis" ) ;
3
+ var hiredis = require ( "hiredis" ) ;
6
4
7
5
exports . name = "hiredis" ;
8
6
9
7
function HiredisReplyParser ( options ) {
10
8
this . name = exports . name ;
11
9
this . options = options ;
12
10
this . reset ( ) ;
13
- events . EventEmitter . call ( this ) ;
14
11
}
15
12
16
- util . inherits ( HiredisReplyParser , events . EventEmitter ) ;
17
-
18
13
exports . Parser = HiredisReplyParser ;
19
14
20
15
HiredisReplyParser . prototype . reset = function ( ) {
@@ -34,9 +29,9 @@ HiredisReplyParser.prototype.execute = function (data) {
34
29
}
35
30
36
31
if ( reply && reply . constructor === Error ) {
37
- this . emit ( "reply error" , reply ) ;
32
+ this . send_error ( reply ) ;
38
33
} else {
39
- this . emit ( "reply" , reply ) ;
34
+ this . send_reply ( reply ) ;
40
35
}
41
36
}
42
37
} ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- var events = require ( "events" ) ,
4
- util = require ( "util" ) ;
3
+ var util = require ( "util" ) ;
5
4
6
5
function Packet ( type , size ) {
7
6
this . type = type ;
@@ -20,8 +19,6 @@ function ReplyParser(options) {
20
19
this . _reply_type = null ;
21
20
}
22
21
23
- util . inherits ( ReplyParser , events . EventEmitter ) ;
24
-
25
22
exports . Parser = ReplyParser ;
26
23
27
24
function IncompleteReadBuffer ( message ) {
@@ -286,11 +283,3 @@ ReplyParser.prototype._packetEndOffset = function () {
286
283
ReplyParser . prototype . _bytesRemaining = function ( ) {
287
284
return ( this . _buffer . length - this . _offset ) < 0 ? 0 : ( this . _buffer . length - this . _offset ) ;
288
285
} ;
289
-
290
- ReplyParser . prototype . send_error = function ( reply ) {
291
- this . emit ( "reply error" , reply ) ;
292
- } ;
293
-
294
- ReplyParser . prototype . send_reply = function ( reply ) {
295
- this . emit ( "reply" , reply ) ;
296
- } ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ describe('javascript parser', function () {
11
11
assert . deepEqual ( reply , [ [ 'a' ] ] , "Expecting multi-bulk reply of [['a']]" ) ;
12
12
reply_count ++ ;
13
13
}
14
- parser . on ( "reply" , check_reply ) ;
14
+ parser . send_reply = check_reply ;
15
15
16
16
parser . execute ( new Buffer ( '*1\r\n*1\r\n$1\r\na\r\n' ) ) ;
17
17
You can’t perform that action at this time.
0 commit comments