Skip to content

Instantly share code, notes, and snippets.

@shesek
Last active March 24, 2016 10:49
Show Gist options
  • Save shesek/4705172 to your computer and use it in GitHub Desktop.
Save shesek/4705172 to your computer and use it in GitHub Desktop.
setTimeout and setInterval with nicer syntax for CoffeeScript, purely for syntactic sugar
{ "name": "timer-sugar", "version": "0.0.1", "main": "timers.coffee", "license": "BSD" }
module.exports =
wait: (ms, fn) -> setTimeout fn, ms
repeat: (ms, fn) -> setInterval fn, ms
###
npm install git://gist.github.com/4705172
{ wait, repeat } = require 'timer-sugar'
--
Having to do that:
setTimeout (->
foo
bar
), 1000
is ugly and annoying. this allows to write that instead:
wait 1000, ->
foo
bar
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment