mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-22 21:28:11 -05:00
24 lines
595 B
JavaScript
24 lines
595 B
JavaScript
// Generated by CoffeeScript 2.0.0-alpha
|
|
var countdown, sleep;
|
|
|
|
sleep = function(ms) {
|
|
return new Promise(function(resolve) {
|
|
return window.setTimeout(resolve, ms);
|
|
});
|
|
};
|
|
|
|
countdown = async function(seconds) {
|
|
var i, j, ref, utterance;
|
|
for (i = j = ref = seconds; ref <= 1 ? j <= 1 : j >= 1; i = ref <= 1 ? ++j : --j) {
|
|
if (window.speechSynthesis != null) {
|
|
utterance = new SpeechSynthesisUtterance("" + i);
|
|
window.speechSynthesis.speak(utterance);
|
|
}
|
|
console.log(i);
|
|
await sleep(1000);
|
|
}
|
|
return alert("Done! (Check the console!)");
|
|
};
|
|
|
|
countdown(3);
|