<commit_before>var net = require("net"),
    hiredis = require('bindings')('hiredis.node');

exports.Reader = hiredis.Reader;

exports.writeCommand = function() {
    var i, args = arguments;
    var str = "*" + args.length + "\r\n";
    for (i = 0; i < args.length; i++) {
        var arg = args[i];
        str += "$" + arg.length + "\r\n" + arg + "\r\n";
    }
    return str;
}

exports.createConnection = function(port, host) {
    var s = net.createConnection(port || 6379, host);
    var r = new hiredis.Reader();
    var _write = s.write;

    s.write = function() {
        var str = exports.writeCommand.apply(this, arguments);
        return _write.call(s, str);
    }

    s.on("data", function(data) {
        var reply;
        r.feed(data);
        try {
            while((reply = r.get()) !== undefined)
                s.emit("reply", reply);
        } catch(err) {<commit_msg>Bufferify writeCommand, fixes failing write tests.<commit_after>var net = require("net"),
    hiredis = require('bindings')('hiredis.node');

var bufStar = new Buffer("*", "ascii");
var bufDollar = new Buffer("$", "ascii");
var bufCrlf = new Buffer("\r\n", "ascii");

exports.Reader = hiredis.Reader;

exports.writeCommand = function() {
    var args = arguments,
        bufLen = new Buffer(String(args.length), "ascii"),
        parts = [bufStar, bufLen, bufCrlf],
        size = 3 + bufLen.length;

    for (var i = 0; i < args.length; i++) {
        var arg = args[i];
        if (!Buffer.isBuffer(arg))
            arg = new Buffer(String(arg));

        bufLen = new Buffer(String(arg.length), "ascii");
        parts = parts.concat([
            bufDollar, bufLen, bufCrlf,
            arg, bufCrlf
        ]);
        size += 5 + bufLen.length + arg.length;
    }

    return Buffer.concat(parts, size);
}

exports.createConnection = function(port, host) {
    var s = net.createConnection(port || 6379, host);
    var r = new hiredis.Reader();
    var _write = s.write;

    s.write = function() {
        var data = exports.writeCommand.apply(this, arguments);
        return _write.call(s, data);
    }

    s.on("data", function(data) {
        var reply;
        r.feed(data);
        try {
            while((reply = r.get()) !== undefined)
                s.emit("reply", reply);
        } catch(err) {
{'fraction_non_alphanumeric': 0.16306228373702422, 'fraction_numerical': 0.005190311418685121, 'mean_word_length': 2.3280575539568344, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '41094', 'n_tokens_mistral': 758, 'n_tokens_neox': 734, 'n_words': 181}