Skip to content

Instantly share code, notes, and snippets.

@jcollum-hcg
Last active August 29, 2015 13:56
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 jcollum-hcg/9216786 to your computer and use it in GitHub Desktop.
Save jcollum-hcg/9216786 to your computer and use it in GitHub Desktop.
sample of a repeatable async task with confirmation of repeat
readline = require("readline")
log = console.log
rl = readline.createInterface(
input: process.stdin
output: process.stdout
)
asyncTask = (cb) ->
log "starting task"
setTimeout( (-> cb()), 5000)
ask = () ->
rl.question "Hit enter to start, q to quit ", (answer) ->
if answer == "q"
process.exit()
else asyncTask ->
log "done with task"
ask()
ask()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment