From ceca0918161c2573e67e203fed24dc768d9951c7 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Tue, 22 Nov 2016 21:53:03 -0800 Subject: [PATCH] Relocate example per new folder structure; update per final notes --- .../{coffee => examples}/async.coffee | 9 +++++--- documentation/js/async.js | 23 ------------------- 2 files changed, 6 insertions(+), 26 deletions(-) rename documentation/{coffee => examples}/async.coffee (65%) delete mode 100644 documentation/js/async.js diff --git a/documentation/coffee/async.coffee b/documentation/examples/async.coffee similarity index 65% rename from documentation/coffee/async.coffee rename to documentation/examples/async.coffee index 23dd85f0..1b95b6ee 100644 --- a/documentation/coffee/async.coffee +++ b/documentation/examples/async.coffee @@ -1,15 +1,18 @@ +# Your browser must support async/await and speech synthesis +# to run this example. + sleep = (ms) -> new Promise (resolve) -> window.setTimeout resolve, ms say = (text) -> - window.speechSynthesis.cancel() # cancel any prior utterances + window.speechSynthesis.cancel() window.speechSynthesis.speak new SpeechSynthesisUtterance text countdown = (seconds) -> for i in [seconds..1] - say "#{i}" + say i await sleep 1000 # wait one second say "Blastoff!" -countdown(3) +countdown 3 diff --git a/documentation/js/async.js b/documentation/js/async.js deleted file mode 100644 index 5c13b246..00000000 --- a/documentation/js/async.js +++ /dev/null @@ -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);