<commit_before>(function() {

	var defaults = {
		// True when url param debug_assets=true.
		isDebugging: false,
		// Jammit dependency management/config file.
		assets: 'assets.yml',
		// List of javascript assets; name of assets should match `javascripts` packages defined in assets.yml.
		jsAssets: [],
		// List of css assets; name of assets should match `stylesheets` packages defined in assets.yml.
		cssAssets: [], 
		// Environment which determines how gettit loads.
		env: 'production',
		// Prepended to `jsAssets` and `cssAssets` when fetching files.
		path: '',
		// The namespace where templates are compiled.
		templateNs: 'window.JST',
		// The extension used to identify javascript templates.
		templateExt: 'jst',
		// The function used to compile javascript templates.
		templateFunc: '',
		// Version number appended to request urls as a query param. Useful for busting cache.
		version: '',
		// Callback called after all javascripts/templates are loaded.
		cb: '(function(){})'
	};

	// Use the `options` to find out what mode/environment we are in - production or 
	// debug/development - and load assets accordingly. In production, load js and css
	// using the given `options`. In debug/development, fetch the `options.assets` file.
	var load = function(options) {
		var params = extend(defaults, options),
			cb = function() { params.cb && eval(params.cb+'()'); };
		var cacheBust = '?r=' + params.version || new Date().getTime()

		if(params.env == 'production' && !params.isDebugging) {
			// Production mode - fetch assets from params directly.
			fetchAssets(params.jsAssets, params.cssAssets, params.path, cacheBust, cb);
		} else {
			// Development/debug mode - get package names from the filenames in `jsAssets` and `cssAssets`. 
			var jsPackages = [], cssPackages = [];
			each(params.jsAssets, function(asset) {
				jsPackages.push(getFileName(asset));
			});
			each(params.cssAssets, function(asset) {
				cssPackages.push(getFileName(asset));
			});

			// Fetch the yaml file. In the callback, parse out and fetch the scripts, templates, and stylesheets.	
			fetchText(params.path+params.assets, cacheBust, function(text) {
				var yaml = YAML.eval(text), scripts = [], css = [], templates = [];
				extend(params, {
					templateFunc: yaml.template_function,
					templateNs: yaml.template_namespace,
					templateExt: yaml.template_extension
				});

				// Use the `javascripts` yaml definition to create `scripts` and `templates` file lists.
				each(keys(yaml.javascripts), function(packageName) {
					if(indexOf(jsPackages, packageName) > -1) {
						each(yaml.javascripts[packageName], function(js) {
							if(js.substr(js.length-3) == '.js')
								scripts.push(js);
							else if(js.substr(js.length-params.templateExt.length) == params.templateExt)
								templates.push(js);
						});
					}
				});
				
				// Use the `stylesheets` yaml definition to create a `css` file list.
				each(keys(yaml.stylesheets), function(packageName) {
					if(indexOf(cssPackages, packageName) > -1)
						css = css.concat(yaml.stylesheets[packageName]);
				});
			
				// Fetch the assets parsed from yaml. In the callback, fetch and compile the templates.
				fetchAssets(scripts, css, params.path, cacheBust, function() {
					if(!templates.length) cb();
					var nTemplates = 0;
					each(templates, function(template) {
						fetchText(params.path+template, cacheBust, function(text) {
							templateCompiler.compile(params.templateNs, getFileName(template), text, params.templateFunc);
							if(++nTemplates === templates.length) cb();
						});
					});
				});
			});
		}
	};
	

	// Utilities
	// ---------
	
	// Given arrays of `js` and `css` files, prepends the `path` and fetches them. Javascript is
	// downloaded in parallel, but executed in order. If `bust` is defined, then that value is 
	// appended to each url. The callback ,`cb`, is fired after the last javascript executes.
	function fetchAssets(js, css, path, bust, cb) {
		if(css) {
			each(css, function(file) { 
				var el = document.createElement('link');
				el.href = (file.indexOf('://')  >  0  ? file : path + file) + (bust?bust:'');
				el.rel = 'stylesheet';
				el.type = 'text/css';
				document.getElementsByTagName('head')[0].appendChild(el);<commit_msg>assured loading order for packages defined in js-assets and css-assets<commit_after>(function() {

	var defaults = {
		// True when url param debug_assets=true.
		isDebugging: false,
		// Jammit dependency management/config file.
		assets: 'assets.yml',
		// List of javascript assets; name of assets should match `javascripts` packages defined in assets.yml.
		jsAssets: [],
		// List of css assets; name of assets should match `stylesheets` packages defined in assets.yml.
		cssAssets: [], 
		// Environment which determines how gettit loads.
		env: 'production',
		// Prepended to `jsAssets` and `cssAssets` when fetching files.
		path: '',
		// The namespace where templates are compiled.
		templateNs: 'window.JST',
		// The extension used to identify javascript templates.
		templateExt: 'jst',
		// The function used to compile javascript templates.
		templateFunc: '',
		// Version number appended to request urls as a query param. Useful for busting cache.
		version: '',
		// Callback called after all javascripts/templates are loaded.
		cb: '(function(){})'
	};

	// Use the `options` to find out what mode/environment we are in - production or 
	// debug/development - and load assets accordingly. In production, load js and css
	// using the given `options`. In debug/development, fetch the `options.assets` file.
	var load = function(options) {
		var params = extend(defaults, options),
			cb = function() { params.cb && eval(params.cb+'()'); };
		var cacheBust = '?r=' + params.version || new Date().getTime()

		if(params.env == 'production' && !params.isDebugging) {
			// Production mode - fetch assets from params directly.
			fetchAssets(params.jsAssets, params.cssAssets, params.path, cacheBust, cb);
		} else {
			// Development/debug mode - get package names from the filenames in `jsAssets` and `cssAssets`. 
			var jsPackages = [], cssPackages = [];
			each(params.jsAssets, function(asset) {
				jsPackages.push(getFileName(asset));
			});
			each(params.cssAssets, function(asset) {
				cssPackages.push(getFileName(asset));
			});

			// Fetch the yaml file. In the callback, parse out and fetch the scripts, templates, and stylesheets.	
			fetchText(params.path+params.assets, cacheBust, function(text) {
				var yaml = YAML.eval(text), scripts = [], css = [], templates = [];
				extend(params, {
					templateFunc: yaml.template_function,
					templateNs: yaml.template_namespace,
					templateExt: yaml.template_extension
				});

				// Use the `javascripts` yaml definition to create `scripts` and `templates` file lists.
				if(yaml.javascripts) {
					each(jsPackages, function(package) {
						if(yaml.javascripts[package]) {
							each(yaml.javascripts[package], function(js) {
								if(js.substr(js.length-3) == '.js')
									scripts.push(js);
								else if(js.substr(js.length-params.templateExt.length) == params.templateExt)
									templates.push(js);
							});
						}
					});
				}

				// Use the `stylesheets` yaml definition to create a `css` file list.
				if(yaml.stylesheets) {
					each(cssPackages, function(package) {
						if(yaml.stylesheets[package])
							css = css.concat(yaml.stylesheets[package]);
					});
				}
			
				// Fetch the assets parsed from yaml. In the callback, fetch and compile the templates.
				fetchAssets(scripts, css, params.path, cacheBust, function() {
					if(!templates.length) cb();
					var nTemplates = 0;
					each(templates, function(template) {
						fetchText(params.path+template, cacheBust, function(text) {
							templateCompiler.compile(params.templateNs, getFileName(template), text, params.templateFunc);
							if(++nTemplates === templates.length) cb();
						});
					});
				});
			});
		}
	};
	

	// Utilities
	// ---------
	
	// Given arrays of `js` and `css` files, prepends the `path` and fetches them. Javascript is
	// downloaded in parallel, but executed in order. If `bust` is defined, then that value is 
	// appended to each url. The callback ,`cb`, is fired after the last javascript executes.
	function fetchAssets(js, css, path, bust, cb) {
		if(css) {
			each(css, function(file) { 
				var el = document.createElement('link');
				el.href = (file.indexOf('://')  >  0  ? file : path + file) + (bust?bust:'');
				el.rel = 'stylesheet';
				el.type = 'text/css';
				document.getElementsByTagName('head')[0].appendChild(el);
{'fraction_non_alphanumeric': 0.13430589324997105, 'fraction_numerical': 0.001157809424568716, 'mean_word_length': 3.3233233233233235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '279039', 'n_tokens_mistral': 3102, 'n_tokens_neox': 2535, 'n_words': 768}