mirror of
				https://github.com/reality/dbot.git
				synced 2025-11-04 02:17:36 +01:00 
			
		
		
		
	addTimeout for timers module [#494]
This commit is contained in:
		
							parent
							
								
									32b89794cb
								
							
						
					
					
						commit
						8a7333cef3
					
				@ -34,6 +34,18 @@ var timers = function(dbot) {
 | 
			
		||||
                    }
 | 
			
		||||
                }.bind(this), timeout));
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
 | 
			
		||||
        'addTimeout': function(date, callback, params) {
 | 
			
		||||
            var now = new Date().getTime()
 | 
			
		||||
                timeout = date.getTime() - now;
 | 
			
		||||
            this.runningTimeouts.push(setTimeout(function() {
 | 
			
		||||
                try {
 | 
			
		||||
                    callback.apply(callback, params);
 | 
			
		||||
                } catch(err) {
 | 
			
		||||
                    console.log('Callback failed: ' + err);
 | 
			
		||||
                }
 | 
			
		||||
            }, timeout));
 | 
			
		||||
        }
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user