<commit_before>'use strict';

var assign       = require('object-assign');
var EventEmitter = require('events').EventEmitter;

var Dispatcher = require('../dispatcher');

var CHANGE_EVENT = 'change';

/**
 * Creates a Flux Store.
 *
 * @param {object}   exports   Defines the 'public' interface of the store.
 * @param {function} callback  Callback registered to listen to the Dispatcher.
 *
 * @returns {object}  Store object, which is also an EventEmitter.
 */
function createStore(exports, callback) {
	var store = assign(new EventEmitter(), {
		emitChange: function() {
			this.emit(CHANGE_EVENT);
		},

		addChangeListener: function(callback) {
			this.addListener(CHANGE_EVENT, callback);
		},

		removeChangeListener: function(callback) {
			this.removeListener(CHANGE_EVENT, callback);
		},
	});

	store               = assign(store, exports);
	store.dispatchToken = Dispatcher.register(callback.bind(store));

	return store;
}

module.exports = createStore;
<commit_msg>Fix issue with 'EventEmitter' max listener limit being reached.<commit_after>'use strict';

var assign       = require('object-assign');
var EventEmitter = require('events').EventEmitter;

var Dispatcher = require('../dispatcher');

var CHANGE_EVENT = 'change';

/**
 * Creates a Flux Store.
 *
 * @param {object}   exports   Defines the 'public' interface of the store.
 * @param {function} callback  Callback registered to listen to the Dispatcher.
 *
 * @returns {object}  Store object, which is also an EventEmitter.
 */
function createStore(exports, callback) {
	// Make sure EventEmitter has unlimited listeners!
	var emitter = new EventEmitter();
	    emitter.setMaxListeners(0);

	var store = assign(emitter, {
		emitChange: function() {
			this.emit(CHANGE_EVENT);
		},

		addChangeListener: function(callback) {
			this.addListener(CHANGE_EVENT, callback);
		},

		removeChangeListener: function(callback) {
			this.removeListener(CHANGE_EVENT, callback);
		},
	});

	store               = assign(store, exports);
	store.dispatchToken = Dispatcher.register(callback.bind(store));

	return store;
}

module.exports = createStore;

{'fraction_non_alphanumeric': 0.12275731822474033, 'fraction_numerical': 0.00047214353163361664, 'mean_word_length': 4.232098765432099, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6625939', 'n_tokens_mistral': 644, 'n_tokens_neox': 612, 'n_words': 166}