Skip to content

Instantly share code, notes, and snippets.

@mahnunchik
Created February 28, 2013 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahnunchik/5054406 to your computer and use it in GitHub Desktop.
Save mahnunchik/5054406 to your computer and use it in GitHub Desktop.
wait = (functions, cb)->
completed = []
functions.forEach (func, index)->
func ()->
if completed.indexOf(index) is -1
completed.push(index)
if completed.length is functions.length
cb()
wait [
(cb)->
setInterval ()->
console.log 1
cb()
, 1000
(cb)->
setInterval ()->
console.log 2
cb()
, 100
], ()->
console.log('done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment