Created
November 23, 2016 02:45
-
-
Save o0/d517fbedd73ee759cb3beaf7574bd048 to your computer and use it in GitHub Desktop.
Either monad countdown timer. Requires monet.js
This file contains 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
'use strict'; | |
const tick = level => level.time === 1 ? | |
Left(`Time's up`) : | |
Right(Object.assign({}, level, { time: level.time - 1 })); | |
const countdown = (level) => { | |
console.info(level.time); | |
setTimeout(() => tick(level).cata(console.error, countdown), 1000); | |
}; | |
countdown({ time: 30 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment