<commit_before>/*global window, document, jQuery, Zepto, setInterval, clearInterval */

(function($) {
	'use strict';

	var Apply = {};

	// Apply.util
	// ----------

	var isFunction = function(obj) {
		return typeof obj === 'function';
	};

	var isArray = function(obj) {
		return obj && obj.length && !isFunction(obj);
	};

	var isString = function(obj) {
		return typeof obj === 'string';
	};

	var ajax = function(url, type, options) {
		return $.ajax($.extend(options || {}, {
			url : url,
			type : type || 'GET'
		}));
	};

	var endsWith = function(string, suffix) {
		return string.indexOf(suffix) === string.length - suffix.length;
	};

	var delegateOrHandle = function(method, callback) {
		return function() {
			if (this.parent && this.parent[method]) {
				return this.parent[method].apply(this.parent, arguments);
			}
			return callback.apply(this, arguments);
		};
	};

	Apply.util = {
		ajax : ajax,
		isArray : isArray,
		isFunction : isFunction,
		isString : isString,
		string : {
			endsWith : endsWith
		}
	};

	// Apply.dependency
	// ----------------

	var resources = {};

	var outstanding = {
		deferreds : [],
		add : function(deferred) {
			this.deferreds.push(deferred);
			return deferred;
		},
		wait : function(callback) {
			var deferred = $.when.apply($, this.deferreds);
			if (callback) {
				deferred.then(callback);
			}
			return deferred;
		}
	};

	var dependency = Apply.dependency = function(resource, callback) {
		if (resources[resource]) {
			resources[resource].then(callback);
		} else {
			var deferred = outstanding.add(ajax(resource));
			if (endsWith(resource, '.js')) {
				deferred.then(function(source) {
					/*jslint evil: true */
					return eval(source);
				});
			}
			resources[resource] = deferred.then(callback);
		}
		return resources[resource].promise();
	};

	dependency.wait = $.proxy(outstanding.wait, outstanding);

	// Apply.namespace
	// ---------------

	var namespace = Apply.namespace = function(namespace, object) {
		var obj = window;
		if (namespace) {
			var parts = namespace.split('.');
			for ( var i = 0; i < parts.length; i++) {
				if (i === parts.length - 1) {
					obj[parts[i]] = object;
				} else if (!obj[parts[i]]) {
					obj[parts[i]] = {};
				}
				obj = obj[parts[i]];
			}
		}
		return obj;
	};

	// Apply.mixin
	// -----------

	var invoke = function(chain, args, context) {
		for ( var i = 0; i < chain.length; i++) {
			chain[i].apply(context, args);
		}
	};

	var chain = function(objects, funcName) {
		var chain = [];
		for ( var i = 0; i < objects.length; i++) {
			if (objects[i][funcName]) {
				chain.push(objects[i][funcName]);
			}
		}
		return function() {
			invoke(chain, arguments, this);
		};
	};

	var mixinArgs = function(constructor, oldArguments) {
		var args = $.makeArray(oldArguments);
		return isString(args[0]) ? [ args.shift(), constructor ].concat(args)
				: [ constructor ].concat(args);
	};

	var mixinConstructor = function() {
		var constructor = function() {
			if (!this || this.constructor !== constructor) {
				return mixin.apply(this || {}, mixinArgs(constructor, arguments));
			}
			if (this.init) {
				this.init.apply(this, arguments);
			}
		};
		constructor.mixin = function() {
			return mixin.apply(this, mixinArgs(constructor, arguments));
		};
		constructor.singleton = function() {
			return singleton.apply(this, mixinArgs(constructor, arguments));
		};
		constructor.merge = function(object) {
			$.extend(constructor.prototype, object);
		};
		return constructor;
	};

	var mixin = Apply.mixin = function() {
		var mixins = [];
		var constructor = mixinConstructor();
		var args = $.makeArray(arguments);
		var ns;
		if (isString(args[0])) {
			ns = args.shift();
		}
		for ( var i = 0; i < args.length; i++) {
			var mixin = isFunction(args[i]) ? args[i].prototype : args[i];
			$.extend(constructor.prototype, mixin);
			mixins.push(mixin);
		}
		constructor.prototype.init = chain(mixins, 'init');
		if (ns) {
			namespace(ns, constructor);
		}
		return constructor;
	};

	// Apply.singleton
	// ---------------

	var singleton = function() {
		var ns;
		var args = $.makeArray(arguments);
		if (isString(args[0])) {
			ns = args.shift();
		}
		var instance = new (mixin.apply(this, args))();
		if (ns) {
			namespace(ns, instance);
		}
		return instance;
	};

	// Apply.events
	// ------------<commit_msg>Expose Apply.singleton<commit_after>/*global window, document, jQuery, Zepto, setInterval, clearInterval */

(function($) {
	'use strict';

	var Apply = {};

	// Apply.util
	// ----------

	var isFunction = function(obj) {
		return typeof obj === 'function';
	};

	var isArray = function(obj) {
		return obj && obj.length && !isFunction(obj);
	};

	var isString = function(obj) {
		return typeof obj === 'string';
	};

	var ajax = function(url, type, options) {
		return $.ajax($.extend(options || {}, {
			url : url,
			type : type || 'GET'
		}));
	};

	var endsWith = function(string, suffix) {
		return string.indexOf(suffix) === string.length - suffix.length;
	};

	var delegateOrHandle = function(method, callback) {
		return function() {
			if (this.parent && this.parent[method]) {
				return this.parent[method].apply(this.parent, arguments);
			}
			return callback.apply(this, arguments);
		};
	};

	Apply.util = {
		ajax : ajax,
		isArray : isArray,
		isFunction : isFunction,
		isString : isString,
		string : {
			endsWith : endsWith
		}
	};

	// Apply.dependency
	// ----------------

	var resources = {};

	var outstanding = {
		deferreds : [],
		add : function(deferred) {
			this.deferreds.push(deferred);
			return deferred;
		},
		wait : function(callback) {
			var deferred = $.when.apply($, this.deferreds);
			if (callback) {
				deferred.then(callback);
			}
			return deferred;
		}
	};

	var dependency = Apply.dependency = function(resource, callback) {
		if (resources[resource]) {
			resources[resource].then(callback);
		} else {
			var deferred = outstanding.add(ajax(resource));
			if (endsWith(resource, '.js')) {
				deferred.then(function(source) {
					/*jslint evil: true */
					return eval(source);
				});
			}
			resources[resource] = deferred.then(callback);
		}
		return resources[resource].promise();
	};

	dependency.wait = $.proxy(outstanding.wait, outstanding);

	// Apply.namespace
	// ---------------

	var namespace = Apply.namespace = function(namespace, object) {
		var obj = window;
		if (namespace) {
			var parts = namespace.split('.');
			for ( var i = 0; i < parts.length; i++) {
				if (i === parts.length - 1) {
					obj[parts[i]] = object;
				} else if (!obj[parts[i]]) {
					obj[parts[i]] = {};
				}
				obj = obj[parts[i]];
			}
		}
		return obj;
	};

	// Apply.mixin
	// -----------

	var invoke = function(chain, args, context) {
		for ( var i = 0; i < chain.length; i++) {
			chain[i].apply(context, args);
		}
	};

	var chain = function(objects, funcName) {
		var chain = [];
		for ( var i = 0; i < objects.length; i++) {
			if (objects[i][funcName]) {
				chain.push(objects[i][funcName]);
			}
		}
		return function() {
			invoke(chain, arguments, this);
		};
	};

	var mixinArgs = function(constructor, oldArguments) {
		var args = $.makeArray(oldArguments);
		return isString(args[0]) ? [ args.shift(), constructor ].concat(args)
				: [ constructor ].concat(args);
	};

	var mixinConstructor = function() {
		var constructor = function() {
			if (!this || this.constructor !== constructor) {
				return mixin.apply(this || {}, mixinArgs(constructor, arguments));
			}
			if (this.init) {
				this.init.apply(this, arguments);
			}
		};
		constructor.mixin = function() {
			return mixin.apply(this, mixinArgs(constructor, arguments));
		};
		constructor.singleton = function() {
			return singleton.apply(this, mixinArgs(constructor, arguments));
		};
		constructor.merge = function(object) {
			$.extend(constructor.prototype, object);
		};
		return constructor;
	};

	var mixin = Apply.mixin = function() {
		var mixins = [];
		var constructor = mixinConstructor();
		var args = $.makeArray(arguments);
		var ns;
		if (isString(args[0])) {
			ns = args.shift();
		}
		for ( var i = 0; i < args.length; i++) {
			var mixin = isFunction(args[i]) ? args[i].prototype : args[i];
			$.extend(constructor.prototype, mixin);
			mixins.push(mixin);
		}
		constructor.prototype.init = chain(mixins, 'init');
		if (ns) {
			namespace(ns, constructor);
		}
		return constructor;
	};

	// Apply.singleton
	// ---------------

	var singleton = Apply.singleton = function() {
		var ns;
		var args = $.makeArray(arguments);
		if (isString(args[0])) {
			ns = args.shift();
		}
		var instance = new (mixin.apply(this, args))();
		if (ns) {
			namespace(ns, instance);
		}
		return instance;
	};

	// Apply.events
	// ------------
{'fraction_non_alphanumeric': 0.1844060820852864, 'fraction_numerical': 0.0018291985823710986, 'mean_word_length': 2.9836065573770494, 'pattern_counts': {'":': 0, '<': 11, '<?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': '5737184', 'n_tokens_mistral': 3325, 'n_tokens_neox': 2856, 'n_words': 640}