1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Relocate example per new folder structure; update per final notes

This commit is contained in:
Geoffrey Booth 2016-11-22 21:53:03 -08:00
parent bc471da960
commit ceca091816
2 changed files with 6 additions and 26 deletions

View file

@ -1,15 +1,18 @@
# Your browser must support async/await and speech synthesis
# to run this example.
sleep = (ms) -> sleep = (ms) ->
new Promise (resolve) -> new Promise (resolve) ->
window.setTimeout resolve, ms window.setTimeout resolve, ms
say = (text) -> say = (text) ->
window.speechSynthesis.cancel() # cancel any prior utterances window.speechSynthesis.cancel()
window.speechSynthesis.speak new SpeechSynthesisUtterance text window.speechSynthesis.speak new SpeechSynthesisUtterance text
countdown = (seconds) -> countdown = (seconds) ->
for i in [seconds..1] for i in [seconds..1]
say "#{i}" say i
await sleep 1000 # wait one second await sleep 1000 # wait one second
say "Blastoff!" say "Blastoff!"
countdown(3) countdown 3

View file

@ -1,23 +0,0 @@
// 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);