{"size": 1869, "ext": "js", "max_stars_repo_path": "src/events.js", "max_stars_repo_name": "retailnext/catiline", "max_stars_repo_stars_event_min_datetime": "2015-01-02T08:10:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-16T21:12:00.000Z", "max_issues_repo_path": "src/events.js", "max_issues_repo_name": "retailnext/catiline", "max_issues_repo_issues_event_min_datetime": "2015-01-30T06:55:31.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-26T23:13:17.000Z", "max_forks_repo_path": "src/events.js", "max_forks_repo_name": "harvychen/catiline", "max_forks_repo_forks_event_min_datetime": "2015-01-30T19:23:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-17T06:28:33.000Z"}
{"max_stars_count": 256, "max_issues_count": 10, "max_forks_count": 48, "avg_line_length": 21.9882352941, "max_line_length": 65, "alphanum_fraction": 0.6104868914}
function addEvents(context, msg) {
	const listeners = {};
	let sendMessage;
	if(typeof __self__ !== 'undefined'){
		sendMessage = __self__.postMessage;
	}else if (msg) {
		sendMessage = msg;
	}
	context.on = function(eventName, func, scope) {
		scope = scope || context;
		if (eventName.indexOf(' ') > 0) {
			eventName.split(' ').map(function(v) {
				return context.on(v, func, scope);
			}, this);
			return context;
		}
		if (!(eventName in listeners)) {
			listeners[eventName] = [];
		}
		const newFunc = function(a) {
			func.call(scope, a, scope);
		};
		newFunc.orig = func;
		listeners[eventName].push(newFunc);
		return context;
	};
	context.one = function(eventName, func, scope) {
		scope = scope || context;

		function ourFunc(a) {
			context.off(eventName, ourFunc);
			func.call(scope, a, scope);
		}
		return context.on(eventName, ourFunc);
	};

	context.trigger = function(eventName, data) {
		if (eventName.indexOf(' ') > 0) {
			eventName.split(' ').forEach(function(v) {
				context.trigger(v, data);
			});
			return context;
		}
		if (!(eventName in listeners)) {
			return context;
		}
		listeners[eventName].forEach(function(v) {
			v(data);
		});
		return context;
	};
	context.fire = function(eventName, data, transfer) {
		sendMessage([[eventName],data],transfer);
		return context;
	};
	context.off = function(eventName, func) {
		if (eventName.indexOf(' ') > 0) {
			eventName.split(' ').map(function(v) {
				return context.off(v, func);
			});
			return context;
		}
		if (!(eventName in listeners)) {
			return context;
		}
		else {
			if (func) {
				listeners[eventName] = listeners[eventName].map(function(a) {
					if (a.orig === func) {
						return false;
					}
					else {
						return a;
					}
				}).filter(function(a) {
					return a;
				});
			}
			else {
				delete listeners[eventName];
			}
		}
		return context;
	};
}