Skip to content

Instantly share code, notes, and snippets.

@jjb
Created January 18, 2018 17:40
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 jjb/ab02bfa90b29b1aba96f78bb600dfcae to your computer and use it in GitHub Desktop.
Save jjb/ab02bfa90b29b1aba96f78bb600dfcae to your computer and use it in GitHub Desktop.
Sleep in coffeescript
sleep = (ms)->
date = new Date()
loop
break if (new Date())-date > ms
# from https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep
# as foretold in a million passionate comments by programmers 'round the world,
# using this in business logic in javascript is a bad idea. but it sometimes comes in
# handy when trying to experiment with something in dev (like if you want to simulate
# a timeout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment