Add constantly alias for repeated async loops

This commit is contained in:
deadprogram 2014-02-19 14:12:54 -08:00
parent e74bc148d9
commit bb740c5cc2
2 changed files with 13 additions and 0 deletions

4
dist/utils.js vendored
View File

@ -18,6 +18,10 @@
return setTimeout(action, delay);
};
global.constantly = function(action) {
return every(0, action);
};
global.sleep = function(ms) {
var i, start, _results;
start = Date.now();

View File

@ -34,6 +34,15 @@ global.every = (interval, action) ->
global.after = (delay, action) ->
setTimeout action, delay
# Public: Alias to the `every` function, but passing 0
# Examples
#
# constantly -> console.log("hello world (and again and again)!")
#
# Returns an interval
global.constantly = (action) ->
every 0, action
# Public: Sleep - do nothing for some duration of time.
#
# ms - number of ms to sleep for