<commit_before>(function() {
	var root = (typeof window !== 'undefined' && window !== null) ? window : GLOBAL;

	root.$IMA = root.$IMA || {};

	root.$IMA.Loader = {
		modules: {},
		register: function(moduleName, dependencies, makeModule) {
			var self = this;
			this.modules[moduleName] = {};

			var module = makeModule(function(key, value) {
				self.modules[moduleName][key] = value;
			});

			module.setters.map(function(setter, index) {
				if (!self.modules[dependencies[index]]) {
					throw new Error('$IMA.Loader.register: Dependency ' + dependencies[index] +
							' is not registered. Update your build.js');
				}

				setter(self.modules[dependencies[index]]);
			});

			module.execute();
		},
		import: function(moduleName) {
			if (!this.modules[moduleName]) {
				throw new Error('$IMA.Loader.import: Module name ' + moduleName +
						' is not registered. Update your build.js.');
			}

			return Promise.resolve(this.modules[moduleName]);
		}
	};
})();<commit_msg>asynchronous module loader<commit_after>(function() {
	var root;
	if ((typeof window !== 'undefined') && (window !== null)) {
		root = window;
	} else {
		root = GLOBAL;
	}

	root.$IMA = root.$IMA || {};
	var modules = {};

	root.$IMA.Loader = {
		modules: modules,
		register: function (moduleName, dependencies, moduleFactory) {
			this.modules[moduleName] = {
				dependencies: dependencies,
				factory: moduleFactory,
				instance: null
			};
		},
		import: function (moduleName) {
			if (!this.modules[moduleName]) {
				throw new Error('$IMA.Loader.import: Module name ' +
						moduleName + ' is not registered. Update your ' +
						'build.js.');
			}

			return Promise.resolve(resolveModule(moduleName));
		},
		initAllModules: function () {
			Object.keys(modules).forEach(function (moduleName) {
				resolveModule(moduleName);
			});
		}
	};

	function resolveModule(moduleName, dependencyOf) {
		if (!modules[moduleName]) {
			throw new Error('$IMA.Loader.import: Module name ' +
				moduleName + (
					dependencyOf ?
						(' (dependency of ' + dependencyOf + ')') :
						''
				) + ' is not registered. Update your build.js.');
		}

		var module = modules[moduleName];
		if (module.instance) {
			return module.instance;
		}

		var moduleInstance = {};
		var moduleInitializer = module.factory(function _export(key, value) {
			moduleInstance[key] = value;
		});
		module.instance = moduleInstance; // allow lazy circular dependencies

		var dependencies = module.dependencies.map(function (dependencyName) {
			return resolveModule(dependencyName, moduleName);
		});
		dependencies.forEach(function (dependency, index) {
			moduleInitializer.setters[index](dependency);
		});

		moduleInitializer.execute();

		return moduleInstance;
	}
})();
{'fraction_non_alphanumeric': 0.15211062590975255, 'fraction_numerical': 0.0, 'mean_word_length': 3.627946127946128, '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': '76602', 'n_tokens_mistral': 997, 'n_tokens_neox': 827, 'n_words': 179}