1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-10 11:43:01 +03:00
Files
node-redis/lib/parser/hiredis.js
Ruben Bridgewater b900bd697f Some small parser changes
The small_to_string was actually quite slow
2015-09-21 02:40:07 +02:00

37 lines
788 B
JavaScript

'use strict';
var hiredis = require("hiredis");
function HiredisReplyParser(return_buffers) {
this.name = exports.name;
this.return_buffers = return_buffers;
this.reset();
}
HiredisReplyParser.prototype.reset = function () {
this.reader = new hiredis.Reader({
return_buffers: this.return_buffers || false
});
};
HiredisReplyParser.prototype.execute = function (data) {
var reply;
this.reader.feed(data);
while (true) {
reply = this.reader.get();
if (reply === undefined) {
break;
}
if (reply && reply.constructor === Error) {
this.send_error(reply);
} else {
this.send_reply(reply);
}
}
};
exports.Parser = HiredisReplyParser;
exports.name = "hiredis";