<commit_before>#ifndef __lang_Function__
#define __lang_Function__

////////////////////////////////////////////////////////////////////////////////
// Function

Function.inject(new function() {
#ifdef BROWSER
#ifdef BROWSER_LEGACY
	Function.timers = {};
	var timerId = 0;

#endif // BROWSER_LEGACY
	function timer(that, type, delay, bind, args) {
		// If delay is not defined, execute right away and return the result
		// of the function. This is used in fireEvent.
		if (delay === undefined)
			// IE seems to not support passing undefined for args in apply,
			// so make sure it's always defined:
			return that.apply(bind, args ? args : []);
		var fn = that.bind(bind, args);
#ifdef BROWSER_LEGACY
		var id = timerId++;
		Function.timers[id] = fn;
		var f = 'Function.timers[' + id + ']', call = f + '();';
		// directly erase non-periodic timers
		if (type[0] == 'T') call += ' delete ' + f;
		var timer = window['set' + type](call, delay);
#else // !BROWSER_LEGACY
		var timer = window['set' + type](fn, delay);
#endif // !BROWSER_LEGACY
		fn.clear = function() {
			clearTimeout(timer);
			clearInterval(timer);
#ifdef BROWSER_LEGACY
			delete Function.timers[id];
#endif // BROWSER_LEGACY
		};
		return fn;
	}
#endif // BROWSER

	return {
		_BEANS
		_generics: true,

		/**
		 * Returns the function's name, if not unnamed.
		 */
		getName: function() {
			var match = this.toString().match(/^\s*function\s*(\w*)/);
			return match && match[1];
		},

		/**
		 * Returns the function's parameter names as an array
		 */
		getParameters: function() {
			var str = this.toString().match(/^\s*function[^\(]*\(([^\)]*)/)[1];
			return str ? str.split(/\s*,\s*/) : [];
		},

		/**
		 * Returns the function's body as a string, excluding the surrounding { }
		 */
		getBody: function() {
			return this.toString().match(/^\s*function[^\{]*\{([\u0000-\uffff]*)\}\s*$/)[1];
		},

#ifdef BROWSER
		delay: function(delay, bind, args) {
			return timer(this, 'Timeout', delay, bind, args);
		},

		periodic: function(delay, bind, args) {
			return timer(this, 'Interval', delay, bind, args);
		},
#endif // !BROWSER

		bind: function(bind, args) {
			var that = this;
			return function() {
				return that.apply(bind, args);
			}
		},

		attempt: function(bind, args) {
			var that = this;
			return function() {
				try {
					return that.apply(bind, args);
				} catch (e) {
					return e;
				}
			}
		}
	}
});
// dontEnum these fields, as we iterate through Function.prototype in
// Function.prototype.inject

#ifdef BROWSER_LEGACY

////////////////////////////////////////////////////////////////////////////////
// Function Legacy

// Function.call / apply does not work properly on IE 5 PC / Mac

if (!Function.prototype.apply) {
	var cache = {};

	Function.inject({
		// = Ecma 1.5 apply/call at native speed, with variable argument count,
		// through caching of caller functions<commit_msg>Fixed bugs related to the fact that Function#apply cannot take undefined for arguments on IE.<commit_after>#ifndef __lang_Function__
#define __lang_Function__

////////////////////////////////////////////////////////////////////////////////
// Function

Function.inject(new function() {
#ifdef BROWSER
#ifdef BROWSER_LEGACY
	Function.timers = {};
	var timerId = 0;

#endif // BROWSER_LEGACY
	function timer(that, type, delay, bind, args) {
		// If delay is not defined, execute right away and return the result
		// of the function. This is used in fireEvent.
		if (delay === undefined)
			// IE seems to not support passing undefined for args in apply,
			// so make sure it's always defined:
			return that.apply(bind, args ? args : []);
		var fn = that.bind(bind, args);
#ifdef BROWSER_LEGACY
		var id = timerId++;
		Function.timers[id] = fn;
		var f = 'Function.timers[' + id + ']', call = f + '();';
		// directly erase non-periodic timers
		if (type[0] == 'T') call += ' delete ' + f;
		var timer = window['set' + type](call, delay);
#else // !BROWSER_LEGACY
		var timer = window['set' + type](fn, delay);
#endif // !BROWSER_LEGACY
		fn.clear = function() {
			clearTimeout(timer);
			clearInterval(timer);
#ifdef BROWSER_LEGACY
			delete Function.timers[id];
#endif // BROWSER_LEGACY
		};
		return fn;
	}
#endif // BROWSER

	return {
		_BEANS
		_generics: true,

		/**
		 * Returns the function's name, if not unnamed.
		 */
		getName: function() {
			var match = this.toString().match(/^\s*function\s*(\w*)/);
			return match && match[1];
		},

		/**
		 * Returns the function's parameter names as an array
		 */
		getParameters: function() {
			var str = this.toString().match(/^\s*function[^\(]*\(([^\)]*)/)[1];
			return str ? str.split(/\s*,\s*/) : [];
		},

		/**
		 * Returns the function's body as a string, excluding the surrounding { }
		 */
		getBody: function() {
			return this.toString().match(/^\s*function[^\{]*\{([\u0000-\uffff]*)\}\s*$/)[1];
		},

#ifdef BROWSER
		delay: function(delay, bind, args) {
			return timer(this, 'Timeout', delay, bind, args);
		},

		periodic: function(delay, bind, args) {
			return timer(this, 'Interval', delay, bind, args);
		},
#endif // !BROWSER

		bind: function(bind, args) {
			var that = this;
			return function() {
				return that.apply(bind, args || []);
			}
		},

		attempt: function(bind, args) {
			var that = this;
			return function() {
				try {
					return that.apply(bind, args || []);
				} catch (e) {
					return e;
				}
			}
		}
	}
});
// dontEnum these fields, as we iterate through Function.prototype in
// Function.prototype.inject

#ifdef BROWSER_LEGACY

////////////////////////////////////////////////////////////////////////////////
// Function Legacy

// Function.call / apply does not work properly on IE 5 PC / Mac

if (!Function.prototype.apply) {
	var cache = {};

	Function.inject({
		// = Ecma 1.5 apply/call at native speed, with variable argument count,
		// through caching of caller functions
{'fraction_non_alphanumeric': 0.20543293718166383, 'fraction_numerical': 0.0040747028862478775, 'mean_word_length': 2.540264423076923, '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': '6160482', 'n_tokens_mistral': 2161, 'n_tokens_neox': 1850, 'n_words': 548}