Code coverage report for lib/parsers/hiredis.js

Statements: 100% (22 / 22)      Branches: 100% (8 / 8)      Functions: 100% (3 / 3)      Lines: 100% (22 / 22)      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 39 40 41 42 43    13   13 1087 1087 1087     13 1087         13 2713 2713 2713 6856 6856     1 1     6855 2712     4143 106   4037         13 13  
'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) {
        try {
            reply = this.reader.get();
        } catch (err) {
            // Protocol errors land here
            this.send_error(err);
            break;
        }
 
        if (reply === undefined) {
            break;
        }
 
        if (reply && reply.constructor === Error) {
            this.send_error(reply);
        } else {
            this.send_reply(reply);
        }
    }
};
 
exports.Parser = HiredisReplyParser;
exports.name = 'hiredis';