<commit_before>/*global setTimeout:true, clearTimeout:true */

/**
Tweeny - A teeny tiny JavaScript tweening engine
By <NAME> - <EMAIL>
  v0.1.0

Tweeny and all official extensions are freely available under an MIT license.
For instructions on how to use Tweeny, please consult the manual: https://github.com/jeremyckahn/tweeny/blob/master/README.md

*/

(function Tweeny (global) {
	
	/**
	 * Get the current UNIX time as an integer
	 * @returns {Number} An integer representing the current timestamp.
	 */
	function now () {
		return +new Date();
	}
	
	function each (obj, func) {
		var prop;
		
		for (prop in obj) {
			if (obj.hasOwnProperty(prop)) {
				func(obj, prop);
			}
		}
	}
	
	/**
	 * Does a basic copy of one Object's properties to another.  This is not a robust `extend` function, nor is it recusrsive.  It is only appropriate to use on objects that have primitive properties (Numbers, Strings, Boolean, etc.)
	 * @param {Object} targetObject The object to copy into
	 * @param {Object} srcObject The object to copy from
	 * @returns {Object} A reference to the augmented `targetObj` Object
	 */
	function simpleCopy (targetObj, srcObj) {
		var prop;
		
		for (prop in srcObj) {
			if (srcObj.hasOwnProperty(prop)) {
				targetObj[prop] = srcObj[prop];
			}
		}
		
		return targetObj;
	}
	
	// Modifies the `from` object
	function tweenProps (currentTime, params, state) {
		var prop;
		
		for (prop in state.current) {
			if (state.current.hasOwnProperty(prop) && params.to.hasOwnProperty(prop)) {
				state.current[prop] = params.easingFunc(currentTime - params.timestamp, params.originalState[prop], params.to[prop] - params.originalState[prop], params.duration);
			}
		}
	}
	
	function scheduleUpdate (handler, fps) {
		return setTimeout(handler, 1000 / fps);
	}
	
	function invokeHook (hookName, hooks, context, args) {
		var i;
		
		for (i = 0; i < hooks[hookName].length; i++) {
			hooks[hookName][i].apply(context, args);
		}
	}
	
	function applyFilter (filterName, filters, currentState, originalState, toState) {
		filters[filterName](currentState, originalState, toState);
	}
	
	function timeoutHandler (params, state) {
		var currentTime;
		
		currentTime = now();
		
		if (currentTime < params.timestamp + params.duration && state.isAnimating) {
			// The tween is still running, schedule an update
			tweenProps (currentTime, params, state);
			
			each(global.Tweenable.prototype.filter, function (filters, name) {
				applyFilter('beforeTween', filters[name], state.current, params.originalState, params.to);
			});
			
			if (params.hook.step) {
				invokeHook('step', params.hook, params.context, [state.current]);
			}
			
			params.step.call(state.current);
			state.loopId = scheduleUpdate(function () {
				timeoutHandler(params, state);
			}, params.fps);
		} else {
			// The duration of the tween has expired
			params.tweenController.stop(true);
		}
	}
	
	function Tween (params, state) {
		/**
		 * Stops the tween.
		 * @param {Boolean} gotoEnd If `false`, or omitted, the tween just stops at its current state, and the `callback` is not invoked.  If `true`, the tweened object's values are instantly set the the target values, and the `callbabk` is invoked.
		 */
		this.stop = function stop (gotoEnd) {
			clearTimeout(state.loopId);
			if (gotoEnd) {
				simpleCopy(state.current, params.to);
				state.isAnimating = false;
				params.callback.call(state.current);
			}
		};
		
		// This needs an example file!
		this.pause = function pause () {
			clearTimeout(state.loopId);
			state.pausedAtTime = now();
			state.isPaused = true;
			return this;
		};
		
		this.resume = function play () {
			if (state.isPaused) {
				params.timestamp += state.pausedAtTime - params.timestamp;
			}
			
			scheduleUpdate(function () {
				timeoutHandler(params, state);
			});
			
			return this;
		};
		
		/**
		 * Returns a reference to the tweened object (the `from` object that wat passed to `tweeny.tween`).
		 * @returns {Object}
		 */
		this.get = function get () {
			return state.current;
		};
		
		return this;
	}
	
	function Tweenable () {
		
		this.init = function init () {
			this._hook = {};

			this._tweenParams = {
				hook: this._hook
			};

			this._state = {};

			// The framerate at which Tweeny updates.
			this.fps = 30;

			// The default easing formula.  This can be changed publicly.
			this.easing = 'linear';

			// The default `duration`.  This can be changed publicly.
			this.duration = 500;
			
			return this;
		};
		
		/**
		 * @param {Object} from <commit_msg>Fixed filters and hooks.<commit_after>/*global setTimeout:true, clearTimeout:true */

/**
Tweeny - A teeny tiny JavaScript tweening engine
By <NAME> - <EMAIL>
  v0.1.0

Tweeny and all official extensions are freely available under an MIT license.
For instructions on how to use Tweeny, please consult the manual: https://github.com/jeremyckahn/tweeny/blob/master/README.md

*/

(function Tweeny (global) {
	
	/**
	 * Get the current UNIX time as an integer
	 * @returns {Number} An integer representing the current timestamp.
	 */
	function now () {
		return +new Date();
	}
	
	function each (obj, func) {
		var prop;
		
		for (prop in obj) {
			if (obj.hasOwnProperty(prop)) {
				func(obj, prop);
			}
		}
	}
	
	/**
	 * Does a basic copy of one Object's properties to another.  This is not a robust `extend` function, nor is it recusrsive.  It is only appropriate to use on objects that have primitive properties (Numbers, Strings, Boolean, etc.)
	 * @param {Object} targetObject The object to copy into
	 * @param {Object} srcObject The object to copy from
	 * @returns {Object} A reference to the augmented `targetObj` Object
	 */
	function simpleCopy (targetObj, srcObj) {		
		each(srcObj, function (srcObj, prop) {
			targetObj[prop] = srcObj[prop];
		});
		
		return targetObj;
	}
	
	// Modifies the `from` object
	function tweenProps (currentTime, params, state) {
		var prop;
		
		for (prop in state.current) {
			if (state.current.hasOwnProperty(prop) && params.to.hasOwnProperty(prop)) {
				state.current[prop] = params.easingFunc(currentTime - params.timestamp, params.originalState[prop], params.to[prop] - params.originalState[prop], params.duration);
			}
		}
	}
	
	function scheduleUpdate (handler, fps) {
		return setTimeout(handler, 1000 / fps);
	}
	
	function invokeHook (hookName, hooks, applyTo, args) {
		var i;
		
		for (i = 0; i < hooks[hookName].length; i++) {
			hooks[hookName][i].apply(applyTo, args);
		}
	}
	
	function applyFilter (filterName, filters, applyTo, args) {
		filters[filterName].apply(applyTo, args);
	}
	
	function timeoutHandler (params, state) {
		var currentTime;
		
		currentTime = now();
		
		if (currentTime < params.timestamp + params.duration && state.isAnimating) {
			// The tween is still running, schedule an update
			tweenProps (currentTime, params, state);
			
			each(global.Tweenable.prototype.filter, function (filters, name) {
				applyFilter('beforeTween', filters[name], params.owner, [state.current, params.originalState, params.to]);
			});
			
			if (params.hook.step) {
				invokeHook('step', params.hook, params.owner, [state.current]);
			}
			
			params.step.call(state.current);
			state.loopId = scheduleUpdate(function () {
				timeoutHandler(params, state);
			}, params.fps);
		} else {
			// The duration of the tween has expired
			params.tweenController.stop(true);
		}
	}
	
	function Tween (params, state) {
		/**
		 * Stops the tween.
		 * @param {Boolean} gotoEnd If `false`, or omitted, the tween just stops at its current state, and the `callback` is not invoked.  If `true`, the tweened object's values are instantly set the the target values, and the `callbabk` is invoked.
		 */
		this.stop = function stop (gotoEnd) {
			clearTimeout(state.loopId);
			if (gotoEnd) {
				simpleCopy(state.current, params.to);
				state.isAnimating = false;
				params.callback.call(state.current);
			}
		};
		
		// This needs an example file!
		this.pause = function pause () {
			clearTimeout(state.loopId);
			state.pausedAtTime = now();
			state.isPaused = true;
			return this;
		};
		
		this.resume = function play () {
			if (state.isPaused) {
				params.timestamp += state.pausedAtTime - params.timestamp;
			}
			
			scheduleUpdate(function () {
				timeoutHandler(params, state);
			});
			
			return this;
		};
		
		/**
		 * Returns a reference to the tweened object (the `from` object that wat passed to `tweeny.tween`).
		 * @returns {Object}
		 */
		this.get = function get () {
			return state.current;
		};
		
		return this;
	}
	
	function Tweenable () {
		
		this.init = function init () {
			this._hook = {};

			this._tweenParams = {
				owner: this,
				hook: this._hook
			};

			this._state = {};

			// The framerate at which Tweeny updates.
			this.fps = 30;

			// The default easing formula.  This can be changed publicly.
			this.easing = 'linear';

			// The default `duration`.  This can be changed publicly.
			this.duration = 500;
			
			return this;
		};
		
		/**
		 * @param {Object} from 
{'fraction_non_alphanumeric': 0.1226321036889332, 'fraction_numerical': 0.0028802481444555224, 'mean_word_length': 3.1815655396016673, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '6018378', 'n_tokens_mistral': 3326, 'n_tokens_neox': 2783, 'n_words': 844}