1 /*global Buffer require exports console setTimeout */
3 var events = require("events"),
4 util = require("../util"),
5 hiredis = require("hiredis");
7 exports.debug_mode = false;
8 exports.name = "hiredis";
10 function HiredisReplyParser(options) {
11 this.name = exports.name;
12 this.options = options || {};
14 events.EventEmitter.call(this);
17 util.inherits(HiredisReplyParser, events.EventEmitter);
19 exports.Parser = HiredisReplyParser;
21 HiredisReplyParser.prototype.reset = function () {
22 this.reader = new hiredis.Reader({
23 return_buffers: this.options.return_buffers || false
27 HiredisReplyParser.prototype.execute = function (data) {
29 this.reader.feed(data);
32 reply = this.reader.get();
34 this.emit("error", err);
38 if (reply === undefined) break;
40 if (reply && reply.constructor === Error) {
41 this.emit("reply error", reply);
43 this.emit("reply", reply);