control-timeout
Advanced tools
Comparing version
@@ -95,3 +95,2 @@ // Generated by CoffeeScript 1.10.0 | ||
case 0: | ||
Timeout.log(moduleName + ': no timeouts were found, nothing to run..'); | ||
return null; | ||
@@ -98,0 +97,0 @@ case 1: |
@@ -1,1 +0,1 @@ | ||
(function(){var t,n,e,i=[].slice;e=require("types.js"),n="control-timeout",t=function(){function t(n){this.timeouts={},this.running={},this.delay=Math.abs(n)||t.delay}return t.setLog=function(n){return t.log=e.forceFunction(n)},t.log=t.setLog("undefined"!=typeof console&&null!==console?console.log:void 0),t.delay=0,t.prototype.exists=function(t){return this.timeouts.hasOwnProperty(t)},t.prototype.isRunning=function(t){return this.running.hasOwnProperty(t)},t.prototype._stopOne=function(t){return this.isRunning(t)&&(clearTimeout(this.running[t]),delete this.running[t]),this},t.prototype.stop=function(){var t,n,e,o;if(e=1<=arguments.length?i.call(arguments,0):[],e.length)for(t=0,o=e.length;o>t;t++)n=e[t],this._stopOne(n);else for(n in this.running)this._stopOne(n);return this},t.prototype.setDelay=function(t,n){return this.exists(t)?this.timeouts[t].delay=e.forceNumber(n,this.timeouts[t].delay):void 0},t.prototype.getTimeout=function(t){return this.running[t]},t.prototype._setTimeout=function(t,n,e){return this.running[t]=setTimeout(function(e){return function(){return delete e.running[t],n()}}(this),e)},t.prototype.run=function(){var e,o,s,r,u,l,a;if(o=arguments[0],e=2<=arguments.length?i.call(arguments,1):[],a=[],o)this.exists(o)?a.push(this._setTimeout(o,(u=this.timeouts[o].action).bind.apply(u,[null].concat(i.call(e))),this.timeouts[o].delay)):t.log(n+': timeout with id: "'+o+'" was not found');else{s=this.timeouts;for(o in s)l=s[o],this.isRunning(o)||a.push(this._setTimeout(o,(r=l.action).bind.apply(r,[null].concat(i.call(e))),l.delay))}switch(a.length){case 0:return t.log(n+": no timeouts were found, nothing to run.."),null;case 1:return a[0];default:return a}},t.prototype.removeAll=function(){return this.stop(),this.timeouts={},this},t.prototype.remove=function(){var e,o,s,r;if(s=1<=arguments.length?i.call(arguments,0):[],s.length)for(e=0,r=s.length;r>e;e++)o=s[e],this._stopOne(o),delete this.timeouts[o];else t.log(n+": cannot remove, invalid or non-existing timeout!");return this},t.prototype._add=function(i,o,s){if(e.notString(i)||!i.length)t.log(n+": cannot add timeout, invalid or missing id!");else{if(!this.exists(i))return this.timeouts[i]={action:e.forceFunction(o),delay:Math.abs(e.forceNumber(s,this.delay))},i;t.log(n+": cannot add timeout, id: "+i+" exists already!")}return void 0},t.prototype.add=function(t,n,i){return e.isObject(t)?this._add(t.id,t.action,t.delay):this._add(t,n,i)},t}(),module.exports=t}).call(this); | ||
(function(){var t,n,e,i=[].slice;e=require("types.js"),n="control-timeout",t=function(){function t(n){this.timeouts={},this.running={},this.delay=Math.abs(n)||t.delay}return t.setLog=function(n){return t.log=e.forceFunction(n)},t.log=t.setLog("undefined"!=typeof console&&null!==console?console.log:void 0),t.delay=0,t.prototype.exists=function(t){return this.timeouts.hasOwnProperty(t)},t.prototype.isRunning=function(t){return this.running.hasOwnProperty(t)},t.prototype._stopOne=function(t){return this.isRunning(t)&&(clearTimeout(this.running[t]),delete this.running[t]),this},t.prototype.stop=function(){var t,n,e,o;if(e=1<=arguments.length?i.call(arguments,0):[],e.length)for(t=0,o=e.length;o>t;t++)n=e[t],this._stopOne(n);else for(n in this.running)this._stopOne(n);return this},t.prototype.setDelay=function(t,n){return this.exists(t)?this.timeouts[t].delay=e.forceNumber(n,this.timeouts[t].delay):void 0},t.prototype.getTimeout=function(t){return this.running[t]},t.prototype._setTimeout=function(t,n,e){return this.running[t]=setTimeout(function(e){return function(){return delete e.running[t],n()}}(this),e)},t.prototype.run=function(){var e,o,s,r,u,l,a;if(o=arguments[0],e=2<=arguments.length?i.call(arguments,1):[],a=[],o)this.exists(o)?a.push(this._setTimeout(o,(u=this.timeouts[o].action).bind.apply(u,[null].concat(i.call(e))),this.timeouts[o].delay)):t.log(n+': timeout with id: "'+o+'" was not found');else{s=this.timeouts;for(o in s)l=s[o],this.isRunning(o)||a.push(this._setTimeout(o,(r=l.action).bind.apply(r,[null].concat(i.call(e))),l.delay))}switch(a.length){case 0:return null;case 1:return a[0];default:return a}},t.prototype.removeAll=function(){return this.stop(),this.timeouts={},this},t.prototype.remove=function(){var e,o,s,r;if(s=1<=arguments.length?i.call(arguments,0):[],s.length)for(e=0,r=s.length;r>e;e++)o=s[e],this._stopOne(o),delete this.timeouts[o];else t.log(n+": cannot remove, invalid or non-existing timeout!");return this},t.prototype._add=function(i,o,s){if(e.notString(i)||!i.length)t.log(n+": cannot add timeout, invalid or missing id!");else{if(!this.exists(i))return this.timeouts[i]={action:e.forceFunction(o),delay:Math.abs(e.forceNumber(s,this.delay))},i;t.log(n+": cannot add timeout, id: "+i+" exists already!")}return void 0},t.prototype.add=function(t,n,i){return e.isObject(t)?this._add(t.id,t.action,t.delay):this._add(t,n,i)},t}(),module.exports=t}).call(this); |
{ | ||
"name": "control-timeout", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A timeout class for controlling one or multiple timeouts", | ||
@@ -5,0 +5,0 @@ "main": "control-timeout.min.js", |
Sorry, the diff of this file is not supported yet
15336
-1.33%131
-0.76%