Skip to content

Instantly share code, notes, and snippets.

@brianewing
Created April 28, 2012 13:05
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 brianewing/2518940 to your computer and use it in GitHub Desktop.
Save brianewing/2518940 to your computer and use it in GitHub Desktop.
CoffeeScript helpers
window?.exports = window # allows more conventional client-side 'exporting'
# nicer timeouts/intervals in coffeescript
exports.timeout = (ms, fn) -> setTimeout(fn, ms)
exports.interval = (ms, fn) -> setInterval(fn, ms)
@michaelficarra
Copy link

I prefer this:

@exports ?= this
flip = (fn) -> (a, b, c...) -> fn.apply this, [b, a, c...]
timeout = flip setTimeout
interval = flip setInterval

@brianewing
Copy link
Author

Awesome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment