<commit_before>
var _ = require('underscore')
;

var MockRedisSub = exports.MockRedisSub = function () {
    this.subscriptions = {};
    this.messageListeners = [];
    this.subscriptionListeners = [];
};

_.extend(MockRedisSub.prototype, {
    subscribe: function (channel) {
	var _this = this;
	_this.subscriptions[channel] = 1 + (_this.subscriptions[channel] || 0);
	_.each(_this.subscribeListeners, function (listener) {
	    listener(channel, _.keys(_this.subscriptions).length);
	});
    }
    , unsubscribe: function (channel) {
	delete this.subscriptions[channel];
    }
    , on: function (type, listener) {
	if (type === 'message') {
	    this.messageListeners.push(listener);
	}
	else if (type === 'subscribe') {
	    this.subscribeListeners.push(listener);
	}
    }
    , _receive: function (channel, message) {
	if (this.subscriptions[channel] > 0) {
	    _.each(this.messageListeners, function (listener) {
		listener(channel, message);
	    });
	}
    }
});<commit_msg>Stringify messages in the mock redis subscriber.<commit_after>
var _ = require('underscore')
;

var MockRedisSub = exports.MockRedisSub = function () {
    this.subscriptions = {};
    this.messageListeners = [];
    this.subscriptionListeners = [];
};

_.extend(MockRedisSub.prototype, {
    subscribe: function (channel) {
	var _this = this;
	_this.subscriptions[channel] = 1 + (_this.subscriptions[channel] || 0);
	_.each(_this.subscribeListeners, function (listener) {
	    listener(channel, _.keys(_this.subscriptions).length);
	});
    }
    , unsubscribe: function (channel) {
	delete this.subscriptions[channel];
    }
    , on: function (type, listener) {
	if (type === 'message') {
	    this.messageListeners.push(listener);
	}
	else if (type === 'subscribe') {
	    this.subscribeListeners.push(listener);
	}
    }
    , _receive: function (channel, message) {
	if (this.subscriptions[channel] > 0) {
	    _.each(this.messageListeners, function (listener) {
		listener(channel, JSON.stringify(message));
	    });
	}
    }
});
{'fraction_non_alphanumeric': 0.15338941118258287, 'fraction_numerical': 0.0029688273132112814, 'mean_word_length': 3.8489208633093526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2841696', 'n_tokens_mistral': 646, 'n_tokens_neox': 634, 'n_words': 118}