<commit_before>var Iterator = require('stupid-iterator');

function Delay(opts){
 	var self = {};
	var opts = opts || {};
	var collection = [];
	var tick = opts.tick;
	
	/*
	* Private
	*/

	function init(){
		tick.add(update);
	}

	function update(){
		var now = Date.now();
		for (var i = 0; i < collection.length; i++) {
			var delayObject = collection[i];
			if(delayObject.time <= now){
				delayObject.callback();
				Iterator.remove(delayObject, collection);
			}
		};
	}

	function add(_time, _callback){
		var delayObject = {time: parseInt(_time) + Date.now(), callback: _callback};
		Iterator.add(delayObject, collection);
	}

	/*
	* Public
	*/
	self.add = add;

	/*
	* Init
	*/

	init();

	return self;
}

module.exports = Delay;<commit_msg>added pause, start, destroy<commit_after>var Iterator = require('stupid-iterator');

function Delay(opts){
 	var self = {};
	var opts = opts || {};
	var collection = [];
	var tick = opts.tick;
	
	/*
	* Private
	*/

	function init(){
		start();
	}

	function update(){
		var now = Date.now();
		for (var i = 0; i < collection.length; i++) {
			var delayObject = collection[i];
			if(delayObject.time <= now){
				delayObject.callback();
				Iterator.remove(delayObject, collection);
			}
		};
	}

	function add(_time, _callback){
		var delayObject = {time: parseInt(_time) + Date.now(), callback: _callback};
		Iterator.add(delayObject, collection);
	}

	function pause(){
		tick.remove(update);
	}

	function start(){
		tick.add(update);
	}

	function destroy(){
		collection = [];
	}

	/*
	* Public
	*/
	self.add = add;

	/*
	* Init
	*/

	init();

	return self;
}

module.exports = Delay;
{'fraction_non_alphanumeric': 0.17134146341463416, 'fraction_numerical': 0.0012195121951219512, 'mean_word_length': 3.2958115183246073, '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': '269279', 'n_tokens_mistral': 625, 'n_tokens_neox': 561, 'n_words': 131}