Add constantly alias for repeated async loops
This commit is contained in:
parent
e74bc148d9
commit
bb740c5cc2
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue