<commit_before>// https://github.com/wizard04wsu/Class

(function (){
	
	"use strict";
	
	let _initializing = false;
	
	/*** helper functions ***/
	
	function defineProperty(object, propertyName, value, isWritable, isEnumerable, isConfigurable){
		Object.defineProperty(object, propertyName, { value:value, writable:!!isWritable, enumerable:!!isEnumerable, configurable:!!isConfigurable });
	}
	function isPrimitive(o){ var t; return o===t || o===null || (t = typeof o)==="number" || t==="string" || t==="boolean"; }
	function warn(msg){
		if(window.console){
			if(typeof window.console.warn === "function") window.console.warn(msg);
			else if(typeof window.console.log === "function") window.console.log(msg);
		}
	}
	
	function classNameIsValid(className){
	//checks if the specified classname is valid (note: this doesn't check for reserved words)
		return className !== (void 0) && /^[a-z_$][a-z0-9_$]*$/i.test(className);
	}
	
	/*** shared functions ***/
	
	function _constructorFn(Super){ Super.apply(null, [].slice.call(arguments, 1)); }
	function _emptyFn(){}
	let _classToString = function toString(){ return "function Class() { [custom code] }"; };
	let _instanceToString = function toString(){
		if(classNameIsValid(this.constructor.name)) return "[instance of "+this.constructor.name+"]";
		return "[instance of Class]";
	};
	let _extendToString = function toString(){ return "function extend() { [custom code] }"; };

	/*** base class ***/
	
	//the base Class constructor; it will have two static methods, 'extend' and 'noConflict'
	function Class(){}
	
	defineProperty(Class.prototype, "toString", _instanceToString, true, false, true);
	defineProperty(Class, "toString", _classToString, true, false, true);
	
	
	/**
	 * Creates a new class that inherits from the parent class.
	 * 
	 * @param {object} [options]
	 * @param {string} [options.className] - Used as .name for the class function and in .toString() for instances of the class.
	 * @param {function} [options.constructorFn] - Initializes new instances of the class. A function is passed as the first argument, used to initialize the instance using the parent class' constructor; be sure to call it inside constructorFn (before using `this` or protected members).
	 * @param {function} [options.returnFn] - Returns a value when the constructor is called without using the 'new' keyword.
	 * @param {object} [options.extensions] - Additional and overriding properties and methods for the prototype of the class.
	 * @return {function} - The new class.
	 */
	let extendFn = function extend(options){
		
		if(options === void 0) options = {};
		else if(isPrimitive(options)) throw new TypeError("argument 'options' is not an object");


		/*** create the new constructor ***/

		let constructorFn = typeof(options.constructorFn) === "function" ? options.constructorFn : _constructorFn;
		let returnFn = typeof(options.returnFn) === "function" ? options.returnFn : _emptyFn;

		let newClass = function Class(){
			
			if(this && this instanceof newClass && (this.constructor === newClass.prototype.constructor || _initializing)){
			//A new instance is being created; initialize it.
			//This condition will be true in these cases:
			//  1) The 'new' operator was used to instantiate this class
			//  2) The 'new' operator was used to instantiate a subclass, and the subclass' constructorFn() calls its first argument (the bound superFn)
			//  3) The 'new' operator was used to instantiate a subclass, and the subclass' constructorFn() includes something like `MySuperClass.call(this)`
			//  4) Possibly if the prototype chain has been screwed with

				let newInstance = this;

				if(newInstance.constructor === newClass.prototype.constructor){
				//this function is the constructor of the new instance (i.e., it's not a parent class' constructor)
					
					defineProperty(newInstance, "constructor", newClass, true, false, true);
				}

				let _protected,
					superFnCalled = false;
				let superFn = function Super(){
					
					if(superFnCalled) return;	//don't initialize it more than once
					superFnCalled = true;
					
					//initialize the instance using the parent class
					_protected = newClass.prototype.constructor.apply(newInstance, arguments) || {};
					
					//add the protected getters/setters to superFn
					for(name in _protected){
						if(Object.prototype.hasOwnProperty.call(_protected, name)){
							Object.defineProperty(superFn, name, {
								get:(_protected[name].get ? _protected[name].get.bind(newInstance) : void 0),
								set:(_protected[name].set ? _protected[name].set.bind(newInstance) : void 0),
								enumerable:true, configurable:true
							});
						}
					}
					
					/**
					 * Stores a getter and a setter (at least one, if not both), allowing a subclass' constructorFn to access a variable or function that is inside this class' constructorFn.
					 *
					 * @param {string} name
					 * @param {function} [getter]
					 * @param {function} [setter]
					 */
					defineProperty(superFn, "addProtectedMember",
						function addProtectedMember(name, getter, setter){
							if(name === (void 0) || ""+name === "") throw new TypeError("argument 'name' is required");
							if(getter !== (void 0) && typeof(getter) !== "function") throw new TypeError("argument 'getter' is not a function");
							if(setter !== (void 0) && typeof(setter) !== "function") throw new TypeError("argument 'setter' is not a function");
							if(!getter && !setter) return;

							_protected[name] = {get:getter, set:setter};
						},
						false, false, true);
					
					/**
					 * Removes a stored getter & setter, preventing a subclass' constructorFn from accessing the (now private) member.
					 *
					 * @param {string} name
					 */
					defineProperty(superFn, "removeProtectedMember",
						function removeProtectedMember(name){
							if(name === (void 0) || ""+name === "") throw new TypeError("argument 'name' is required");
							
							delete _protected[name];
						},
						false, false, true);
					
				}
		
				//construct the new instance
				_initializing = true;
				//constructorFn.apply(newInstance, [superFn].concat([].slice.call(arguments)));
				constructorFn.bind(newInstance, superFn).apply(null, arguments);
				_initializing = false;
				
				let className = newClass.name;	//store it in case the constructor changes the .name attribute
				if(!superFnCalled) warn(className+" constructor does not include a call to the 'Super' argument");
				
				if(newInstance.constructor !== newClass){
				//this function is the constructor of a super-class
					<commit_msg>Update Class.js<commit_after>// https://github.com/wizard04wsu/Class

(function (){
	
	"use strict";
	
	let _initializing = false;
	
	/*** helper functions ***/
	
	function defineProperty(object, propertyName, value, isWritable, isEnumerable, isConfigurable){
		Object.defineProperty(object, propertyName, { value:value, writable:!!isWritable, enumerable:!!isEnumerable, configurable:!!isConfigurable });
	}
	function isPrimitive(o){ var t; return o===t || o===null || (t = typeof o)==="number" || t==="string" || t==="boolean"; }
	function warn(msg){
		if(window.console){
			if(typeof window.console.warn === "function") window.console.warn(msg);
			else if(typeof window.console.log === "function") window.console.log(msg);
		}
	}
	
	function classNameIsValid(className){
	//checks if the specified classname is valid (note: this doesn't check for reserved words)
		return className !== (void 0) && /^[a-z_$][a-z0-9_$]*$/i.test(className);
	}
	
	/*** shared functions ***/
	
	function _constructorFn(Super){ Super.apply(null, [].slice.call(arguments, 1)); }
	function _emptyFn(){}
	let _classToString = function toString(){ return "function Class() { [custom code] }"; };
	let _instanceToString = function toString(){
		if(classNameIsValid(this.constructor.name)) return "[instance of "+this.constructor.name+"]";
		return "[instance of Class]";
	};
	let _extendToString = function toString(){ return "function extend() { [custom code] }"; };

	/*** base class ***/
	
	//the base Class constructor; it will have two static methods, 'extend' and 'noConflict'
	function Class(){}
	
	defineProperty(Class.prototype, "toString", _instanceToString, true, false, true);
	defineProperty(Class, "toString", _classToString, true, false, true);
	
	
	/**
	 * Creates a new class that inherits from the parent class.
	 * 
	 * @param {object} [options]
	 * @param {string} [options.className] - Used as .name for the class function and in .toString() for instances of the class.
	 * @param {function} [options.constructorFn] - Initializes new instances of the class. A function is passed as the first argument, used to initialize the instance using the parent class' constructor; be sure to call it inside constructorFn (before using `this` or protected members).
	 * @param {function} [options.returnFn] - Returns a value when the constructor is called without using the 'new' keyword.
	 * @param {object} [options.extensions] - Additional and overriding properties and methods for the prototype of the class.
	 * @return {function} - The new class.
	 */
	let extendFn = function extend(options){
		
		if(options === void 0) options = {};
		else if(isPrimitive(options)) throw new TypeError("argument 'options' is not an object");


		/*** create the new constructor ***/

		let constructorFn = typeof(options.constructorFn) === "function" ? options.constructorFn : _constructorFn;
		let returnFn = typeof(options.returnFn) === "function" ? options.returnFn : _emptyFn;

		let newClass = function Class(){
			
			if(this && this instanceof newClass && (this.constructor === newClass.prototype.constructor || _initializing)){
			//A new instance is being created; initialize it.
			//This condition will be true in these cases:
			//  1) The 'new' operator was used to instantiate this class
			//  2) The 'new' operator was used to instantiate a subclass, and the subclass' constructorFn() calls its first argument (the bound superFn)
			//  3) The 'new' operator was used to instantiate a subclass, and the subclass' constructorFn() includes something like `MySuperClass.call(this)`
			//  4) Possibly if the prototype chain has been screwed with

				let newInstance = this;

				if(newInstance.constructor === newClass.prototype.constructor){
				//this function is the constructor of the new instance (i.e., it's not a parent class' constructor)
					
					defineProperty(newInstance, "constructor", newClass, true, false, true);
				}

				let _protected,
					superFnCalled = false;
				let superFn = function Super(){
					
					if(superFnCalled) return;	//don't initialize it more than once
					superFnCalled = true;
					
					//initialize the instance using the parent class
					_protected = newClass.prototype.constructor.apply(newInstance, arguments) || {};
					
					//add the protected getters/setters to superFn
					for(name in _protected){
						if(Object.prototype.hasOwnProperty.call(_protected, name)){
							Object.defineProperty(superFn, name, {
								get:(_protected[name].get ? _protected[name].get.bind(newInstance) : void 0),
								set:(_protected[name].set ? _protected[name].set.bind(newInstance) : void 0),
								enumerable:true, configurable:true
							});
						}
					}
					
					/**
					 * Stores a getter and a setter (at least one, if not both), allowing a subclass' constructorFn to access a variable or function that is inside this class' constructorFn.
					 *
					 * @param {string} name
					 * @param {function} [getter]
					 * @param {function} [setter]
					 */
					defineProperty(superFn, "addProtectedMember",
						function addProtectedMember(name, getter, setter){
							if(name === (void 0) || ""+name === "") throw new TypeError("argument 'name' is required");
							if(getter !== (void 0) && typeof(getter) !== "function") throw new TypeError("argument 'getter' is not a function");
							if(setter !== (void 0) && typeof(setter) !== "function") throw new TypeError("argument 'setter' is not a function");
							if(!getter && !setter) return;

							_protected[name] = {get:getter, set:setter};
						},
						false, false, true);
					
					/**
					 * Removes a stored getter & setter, preventing a subclass' constructorFn from accessing the (now private) member.
					 *
					 * @param {string} name
					 */
					defineProperty(superFn, "removeProtectedMember",
						function removeProtectedMember(name){
							if(name === (void 0) || ""+name === "") throw new TypeError("argument 'name' is required");
							
							delete _protected[name];
						},
						false, false, true);
					
				}
		
				//construct the new instance
				_initializing = true;
				//constructorFn.bind(newInstance, superFn).apply(null, arguments);
				constructorFn.apply(newInstance, [superFn].concat([].slice.call(arguments)));	//(This method doesn't create another new function every time a constructor is run.)
				_initializing = false;
				
				let className = newClass.name;	//store it in case the constructor changes the .name attribute
				if(!superFnCalled) warn(className+" constructor does not include a call to the 'Super' argument");
				
				if(newInstance.constructor !== newClass){
				//this function is the constructor of a super-class
					
{'fraction_non_alphanumeric': 0.12859394940319796, 'fraction_numerical': 0.002552360933863824, 'mean_word_length': 3.705757682797598, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1620042', 'n_tokens_mistral': 4451, 'n_tokens_neox': 3614, 'n_words': 1244}