Last active
August 29, 2015 14:19
-
-
Save mouseroot/ca6ded302b7a337b1cb9 to your computer and use it in GitHub Desktop.
Delay.js - Simple wrapper around setTimout to cleanup the handle refs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var Delay; | |
Delay = function(callback, time, args) { | |
var _timer; | |
_timer = setTimeout(function() { | |
if (!args) { | |
callback(); | |
} else { | |
callback(args); | |
} | |
clearTimeout(_timer); | |
}, time); | |
}; | |
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Delay = (callback, time, args) -> | |
_timer = setTimeout () -> | |
if !args | |
callback() | |
else | |
callback args | |
clearTimeout _timer | |
return | |
, time | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment