Last active
March 24, 2016 10:49
-
-
Save shesek/4705172 to your computer and use it in GitHub Desktop.
setTimeout and setInterval with nicer syntax for CoffeeScript, purely for syntactic sugar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "name": "timer-sugar", "version": "0.0.1", "main": "timers.coffee", "license": "BSD" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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