Code coverage report for lib/parsers/hiredis.js

Statements: 100% (19 / 19)      Branches: 100% (4 / 4)      Functions: 100% (3 / 3)      Lines: 100% (19 / 19)      Ignored: none     

All files » lib/parsers/ » hiredis.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38    13   13 1074 1074         13 17503 17503     2 2       13 3044 3044   3044 14471 105   14366   14459       13 13  
'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';