Files
coffeescript/documentation/js/async.js
2016-11-06 02:30:01 -08:00

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);