# Code coverage report for lib/parser/hiredis.js

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

All files » lib/parser/ » 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

    13

    13
    1175
    1175
    1175

    13
    1175

    13
    3202
    3202
    3202
    8138

    8138
    3202

    4936
    109

    4827

    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) {
            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";