<commit_before>var
	cservice = require("../cluster-service")
;

module.exports = exports = trigger;

function trigger(eventName) {
	var evt = cservice.locals.events[eventName];
	if (!evt) {
		throw new Error("Event " + eventName + " not found");
	}

	var args = [evt]; // event is always first arg
	if (arguments.length > 1) { // grab custom args
		for (var i = 1; i < arguments.length; i++) {
			args.push(arguments[i]);
		}
	}
//exports.log("trigger." + eventName + ".args=" + args.length);
	// invoke event callback
	return evt.cb.apply(null, args);
}<commit_msg>do not throw if callback provided<commit_after>var
	cservice = require("../cluster-service")
;

module.exports = exports = trigger;

function trigger(eventName) {
	var evt = cservice.locals.events[eventName];
	if (!evt) {
        if (typeof arguments[1] === "function") { // invoke callback if provided instead of throwing
            arguments[1]("Event " + eventName + " not found");
        } else {
		    throw new Error("Event " + eventName + " not found");
        }
	}

	var args = [evt]; // event is always first arg
	if (arguments.length > 1) { // grab custom args
		for (var i = 1; i < arguments.length; i++) {
			args.push(arguments[i]);
		}
	}
//exports.log("trigger." + eventName + ".args=" + args.length);
	// invoke event callback
	return evt.cb.apply(null, args);
}
{'fraction_non_alphanumeric': 0.1633259094283593, 'fraction_numerical': 0.004454342984409799, 'mean_word_length': 3.238993710691824, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3774475', 'n_tokens_mistral': 446, 'n_tokens_neox': 435, 'n_words': 123}