<commit_before>
var _ = require('underscore')
, EventEmitter = require('events').EventEmitter
;


var RedisEmitter = exports.RedisEmitter = function(redisSub) {
    this._redisSub = redisSub;
    var emitter = this._emitter = new EventEmitter();
    redisSub.on('message', function (channel, message) {
	emitter.emit(channel, _.toArray(arguments));
    });
};

_.extend(RedisEmitter.prototype, {
    subscribe: function (channel, listener) {
	var _this = this
	, emitter = _this._emitter;
	;
	emitter.on(channel, listener);
	if (_this._numListeners(channel) === 1) {
	    _this._redisSub.subscribe(channel);
	}

    }
    , unsubscribe: function (channel, listener) {
	var _this = this
	, emitter = _this._emitter
	;
	emitter.removeListener(channel, listener);
	if (_this._numListeners(channel) < 1) {
	    _this._redisSub.unsubscribe(channel);<commit_msg>Update redisEmitter so that complex messages are transmitted.<commit_after>
var _ = require('underscore')
, EventEmitter = require('events').EventEmitter
;


var RedisEmitter = exports.RedisEmitter = function(redisSub) {
    this._redisSub = redisSub;
    var emitter = this._emitter = new EventEmitter();
    redisSub.on('message', function (channel) {
	var args = [channel].concat(_.map(_.toArray(arguments).slice(1), JSON.parse));
	emitter.emit(channel, args);
    });
};

_.extend(RedisEmitter.prototype, {
    subscribe: function (channel, listener) {
	var _this = this
	, emitter = _this._emitter;
	;
	emitter.on(channel, listener);
	if (_this._numListeners(channel) === 1) {
	    _this._redisSub.subscribe(channel);
	}

    }
    , unsubscribe: function (channel, listener) {
	var _this = this
	, emitter = _this._emitter
	;
	emitter.removeListener(channel, listener);
	if (_this._numListeners(channel) < 1) {
	    _this._redisSub.unsubscribe(channel);
{'fraction_non_alphanumeric': 0.13829201101928373, 'fraction_numerical': 0.0027548209366391185, 'mean_word_length': 4.469879518072289, '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': '1735185', 'n_tokens_mistral': 606, 'n_tokens_neox': 587, 'n_words': 115}