<commit_before>/*
*    Lynx Project
*    Started August 2013
*    ------------------------------------------------------
*    This file is covered under the LynxJS Game Library
*    License. Please read license.txt for more information
*    on usage of this library.
*    ------------------------------------------------------
*    File Name: EventEmitter.js
*    Description: The central event processor in Lynx.
*    Global Variables: Lynx.EventEmitter(), Lynx.Emitter{}, Lynx.Emit(pEvent, pSender)
*/

Lynx.EventEmitter = function(){
	var that = {};

	var events = [];

	/**
	* Descripton: Subscribes the event listener to the given event
	*
	* @this {Lynx.EventEmitter}
	* @param {String} <pEvent> name of event to subscribe to
	* @param {Lynx.EventListener} <pEventListener> Listener to subscribe
	*/	
	that.Subscribe = (function(pEvent,pEventListener)
	{
		if(typeof events[pEvent] == 'undefined')
			events[pEvent] = [];

		events[pEvent].push(pEventListener);
		this.Notify("EventEmitter.Subscribe", this);
	}).bind(that);

	/**
	* Description: Notifies all listeners of an event
	*
	* @this {Lynx.EventEmitter}
	* @param {String} <pEvent> name of event to notify of
	* @param {Object} <pSender> object that is sending the event.
	*/	
	that.Notify = (function(pEvent, pSender)
	{
		if(typeof events[pEvent] == 'undefined')
			return;

		var nextCallback = true;

		for(var i = 0; (i < events[pEvent].length && nextCallback); i++)
			nextCallback = events[pEvent][i].Notify(pEvent, pSender) || true;

		if(!nextCallback)
		{
			//Assume the event was interrupted
			this.Notify(pEvent+".Break", this);
		}

		this.Notify("EventEmitter.Subscribe",this);
	}).bind(that);

	/**
	* Description: Defines a given event to be emitted later.
	*
	* @depreciated
	* @this {Lynx.EventEmitter}
	* @param {String} <pEvent> Event to add
	*/
	that.Define = (function(pEvent)
	{
		if(typeof events[pEvent] != 'undefined')
			return false;

		events[pEvent] = [];
	}).bind(that);

	return that;
};

Lynx.Emitter = new Lynx.EventEmitter();

Lynx.Emit = function(pEvent, pSender){ Lynx.Emitter.Notify(pEvent, pSender); };<commit_msg>Removes a hiccup where the event emitter could fall into an infinite loop of sorts.<commit_after>/*
*    Lynx Project
*    Started August 2013
*    ------------------------------------------------------
*    This file is covered under the LynxJS Game Library
*    License. Please read license.txt for more information
*    on usage of this library.
*    ------------------------------------------------------
*    File Name: EventEmitter.js
*    Description: The central event processor in Lynx.
*    Global Variables: Lynx.EventEmitter(), Lynx.Emitter{}, Lynx.Emit(pEvent, pSender)
*/

Lynx.EventEmitter = function(){
	var that = {};

	var events = [];

	/**
	* Descripton: Subscribes the event listener to the given event
	*
	* @this {Lynx.EventEmitter}
	* @param {String} <pEvent> name of event to subscribe to
	* @param {Lynx.EventListener} <pEventListener> Listener to subscribe
	*/	
	that.Subscribe = (function(pEvent,pEventListener)
	{
		if(typeof events[pEvent] == 'undefined')
			events[pEvent] = [];

		events[pEvent].push(pEventListener);
		this.Notify("EventEmitter.Subscribe", this);
	}).bind(that);

	/**
	* Description: Notifies all listeners of an event
	*
	* @this {Lynx.EventEmitter}
	* @param {String} <pEvent> name of event to notify of
	* @param {Object} <pSender> object that is sending the event.
	*/	
	that.Notify = (function(pEvent, pSender)
	{
		if(typeof events[pEvent] == 'undefined')
			return;

		var nextCallback = true;

		for(var i = 0; (i < events[pEvent].length && nextCallback); i++)
			nextCallback = events[pEvent][i].Notify(pEvent, pSender) || true;

		if(!nextCallback)
		{
			//Assume the event was interrupted
			this.Notify(pEvent+".Break", this);
		}
	}).bind(that);

	/**
	* Description: Defines a given event to be emitted later.
	*
	* @depreciated
	* @this {Lynx.EventEmitter}
	* @param {String} <pEvent> Event to add
	*/
	that.Define = (function(pEvent)
	{
		if(typeof events[pEvent] != 'undefined')
			return false;

		events[pEvent] = [];
	}).bind(that);

	return that;
};

Lynx.Emitter = new Lynx.EventEmitter();

Lynx.Emit = function(pEvent, pSender){ Lynx.Emitter.Notify(pEvent, pSender); };
{'fraction_non_alphanumeric': 0.18499413833528722, 'fraction_numerical': 0.0023446658851113715, 'mean_word_length': 3.086206896551724, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '5183490', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1361, 'n_words': 373}