<commit_before>var classExport = /^(.*?)exports\s*=\s*Class\(/gm;
var class2Export = /(^|\s+)([a-zA-Z0-9\.$]+)\s*=\s*Class\(/gm;

function replacer(base, prefix, name) {
	return prefix + name + '=__class__(function ' + name.replace(/\./g, '_') + '(){return this.init&&this.init.apply(this,arguments)},';
}

exports = function(path, moduleDef, opts) {
	var moduleCtor = moduleDef.path.replace(/(^[.\/]+|\.([^.]+?)$)/g, '').replace(/[\/.]/g, '_');
	moduleDef.src = moduleDef.src
		.replace(classExport, '$1exports=__class__(function ' + moduleCtor + '(){return this.init&&this.init.apply(this,arguments)},')
		.replace(class2Export, replacer);
}<commit_msg>... broke the CPU profiler.  Add both hacks together.<commit_after>
// var F = exports = Class
// exports = Class
var classExport = /^(.*?)exports[ \t]*=[ \t]*Class\(/gm;

// var F = Class
// exports.F = Class
// var F = exports.F = Class
var class2Export = /^(.*?[ \t]+)?([a-zA-Z0-9\.$]+)[ \t]*=[ \t]*Class\(/gm;

function replacer(base, prefix, name) {
	return name + '=__class__;' + (prefix || '') + name + '=' + name + '(function ' + name.replace(/[\.]/g, '_') + '(){return this.init&&this.init.apply(this,arguments)},';
}

exports = function(path, moduleDef, opts) {
	var moduleCtor = moduleDef.path.replace(/(^[.\/]+|\.([^.]+?)$)/g, '').replace(/[\/\-\.]/g, '_');
	moduleDef.src = moduleDef.src
		.replace(classExport, 'var ' + moduleCtor + '=__class__;$1exports=' + moduleCtor + '(function ' + moduleCtor + '(){return this.init&&this.init.apply(this,arguments)},')
		.replace(class2Export, replacer);
}
{'fraction_non_alphanumeric': 0.2659846547314578, 'fraction_numerical': 0.00639386189258312, 'mean_word_length': 4.182119205298013, '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': '4713184', 'n_tokens_mistral': 594, 'n_tokens_neox': 578, 'n_words': 103}