<commit_before>//////////////////////////////////////////////////////////////////////////////////
//		Implement queuable getter setter				//
//////////////////////////////////////////////////////////////////////////////////

/**
 * by default __defineGetter__ support only one function. Same for __defineSetter
 * This is a annoying limitation. This little library declares 2 functions
 * Object.__defineQGetter__ and Object.__defineQGetter__.
 * They behave the same as their native sibling but support multiple functions.
 * Those functions are called in the same order they got registered.
 * 
 * (I have no idea of the reasoning behind this limitation to one function. It seems
 *  useless to me. This remind me of onclick of the DOM instead of a proper .addEventListener) 
*/
(function(){
	/**
	 * Class to implement queueable getter/setter
	 * @param  {Object} baseObject The base object on which we operate
	 * @param  {String} property   The string of property
	 */
	var _QGetterSetter	= function(baseObject, property){
		// sanity check 
		console.assert( typeof(baseObject) === 'object' );
		console.assert( typeof(property) === 'string' );
		// backup the initial value
		var initialValue= baseObject[property];
		// init some local variables
		var _this	= this;
		this._getters	= [];
		this._setters	= [];
		// define the root getter
		baseObject.__defineGetter__(property, function(){
			var value	= baseObject['__'+property];
			for(var i = 0; i < _this._getters.length; i++){
				value	= _this._getters[i](value)
			}
			return value;
		});
		// define the root setter		
		baseObject.__defineSetter__(property, function(value){
			for(var i = 0; i < _this._setters.length; i++){
				value	= _this._setters[i](value)
			}
			baseObject['__'+property] = value;
		});
		// set the initialValue
		baseObject['__'+property]	= initialValue;
	};

	//////////////////////////////////////////////////////////////////////////////////
	// Override prototype of global ```Object```
	Object.prototype.__defineQGetter__	= function(property, getterFn){
		var name	= "__dbgGetSet_" + property;
		// init _QGetterSetter for this property if needed
		this[name]	= this[name] || new _QGetterSetter(this, property);
		// setup the new getter
		this[name]._getters.push(getterFn)
	};

	Object.prototype.__defineQSetter__	= function(property, setterFn){
		var name	= "__dbgGetSet_" + property;
		// init _QGetterSetter for this property if needed
		this[name]	= this[name] || new _QGetterSetter(this, property);
		// setup the new setter
		this[name]._setters.push(setterFn)
	};
})();
<commit_msg>dont force populating foreign namespace<commit_after>//////////////////////////////////////////////////////////////////////////////////
//		Implement queuable getter setter				//
//////////////////////////////////////////////////////////////////////////////////

/**
 * by default __defineGetter__ support only one function. Same for __defineSetter
 * This is a annoying limitation. This little library declares 2 functions
 * Object.__defineQGetter__ and Object.__defineQGetter__.
 * They behave the same as their native sibling but support multiple functions.
 * Those functions are called in the same order they got registered.
 * 
 * (I have no idea of the reasoning behind this limitation to one function. It seems
 *  useless to me. This remind me of onclick of the DOM instead of a proper .addEventListener) 
*/


/**
 * Class to implement queueable getter/setter
 * @param  {Object} baseObject The base object on which we operate
 * @param  {String} property   The string of property
 */
var QGetterSetter	= {};

QGetterSetter.Property	= function(baseObject, property){
	// sanity check 
	console.assert( typeof(baseObject) === 'object' );
	console.assert( typeof(property) === 'string' );
	// backup the initial value
	var initialValue= baseObject[property];
	// init some local variables
	var _this	= this;
	this._getters	= [];
	this._setters	= [];
	// define the root getter
	baseObject.__defineGetter__(property, function getterHandler(){
		var value	= baseObject['__'+property];
		for(var i = 0; i < _this._getters.length; i++){
			value	= _this._getters[i](value, getterHandler.caller, property)
		}
		return value;
	});
	// define the root setter		
	baseObject.__defineSetter__(property, function(value){
		for(var i = 0; i < _this._setters.length; i++){
			value	= _this._setters[i](value)
		}
		baseObject['__'+property] = value;
	});
	// set the initialValue
	baseObject['__'+property]	= initialValue;
};

// export the class in node.js - if running in node.js
if( typeof(window) === 'undefined' )	module.exports	= QGetterSetter;

QGetterSetter.defineGetter	= function(baseObject, property, getterFn){
	var name	= "__dbgGetSet_" + property;
	// init QGetterSetter for this property if needed
	baseObject[name]= baseObject[name] || new QGetterSetter.Property(baseObject, property);
	// setup the new getter
	baseObject[name]._getters.push(getterFn)
}

QGetterSetter.defineSetter	= function(baseObject, property, setterFn){
	var name	= "__dbgGetSet_" + property;
	// init QGetterSetter for this property if needed
	baseObject[name]= baseObject[name] || new QGetterSetter.Property(baseObject, property);
	// setup the new setter
	baseObject[name]._setters.push(setterFn)
}

//////////////////////////////////////////////////////////////////////////////////
// Override prototype of global ```Object```
Object.prototype.__defineQGetter__	= function(property, getterFn){
	QGetterSetter.defineGetter(this, property, getterFn);
};
Object.prototype.__defineQSetter__	= function(property, setterFn){
	QGetterSetter.defineSetter(this, property, setterFn);
};

{'fraction_non_alphanumeric': 0.18949973484178895, 'fraction_numerical': 0.0010606328442637441, 'mean_word_length': 2.854223433242507, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5590714', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1570, 'n_words': 489}