You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
Minor hiredis handling improvement
This commit is contained in:
@@ -4,37 +4,32 @@ var hiredis = require('hiredis');
|
||||
|
||||
function HiredisReplyParser(return_buffers) {
|
||||
this.name = exports.name;
|
||||
this.return_buffers = return_buffers;
|
||||
this.reset();
|
||||
this.reader = new hiredis.Reader({
|
||||
return_buffers: return_buffers
|
||||
});
|
||||
}
|
||||
|
||||
HiredisReplyParser.prototype.reset = function () {
|
||||
this.reader = new hiredis.Reader({
|
||||
return_buffers: this.return_buffers || false
|
||||
});
|
||||
HiredisReplyParser.prototype.return_data = function () {
|
||||
try {
|
||||
return this.reader.get();
|
||||
} catch (err) {
|
||||
// Protocol errors land here
|
||||
this.send_error(err);
|
||||
return void 0;
|
||||
}
|
||||
};
|
||||
|
||||
HiredisReplyParser.prototype.execute = function (data) {
|
||||
var reply;
|
||||
this.reader.feed(data);
|
||||
while (true) {
|
||||
try {
|
||||
reply = this.reader.get();
|
||||
} catch (err) {
|
||||
// Protocol errors land here
|
||||
this.send_error(err);
|
||||
break;
|
||||
}
|
||||
var reply = this.return_data();
|
||||
|
||||
if (reply === undefined) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (reply && reply.constructor === Error) {
|
||||
while (reply !== undefined) {
|
||||
if (reply && reply.name === 'Error') {
|
||||
this.send_error(reply);
|
||||
} else {
|
||||
this.send_reply(reply);
|
||||
}
|
||||
reply = this.return_data();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user