1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/lib/parsers/hiredis.js
2015-11-23 11:30:50 +01:00

38 lines
847 B
JavaScript

'use strict';
var hiredis = require('hiredis');
function HiredisReplyParser(return_buffers) {
this.name = exports.name;
this.reader = new hiredis.Reader({
return_buffers: return_buffers
});
}
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) {
this.reader.feed(data);
var reply = this.return_data();
while (reply !== undefined) {
if (reply && reply.name === 'Error') {
this.send_error(reply);
} else {
this.send_reply(reply);
}
reply = this.return_data();
}
};
exports.Parser = HiredisReplyParser;
exports.name = 'hiredis';