From dc25f462a9ce00252901a22461c459eeeec73e6c Mon Sep 17 00:00:00 2001 From: Gabe Date: Sun, 6 Nov 2016 11:26:34 -0800 Subject: [PATCH] keeping it simple --- documentation/coffee/async.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/documentation/coffee/async.coffee b/documentation/coffee/async.coffee index 4525fe9fe9..23dd85f016 100644 --- a/documentation/coffee/async.coffee +++ b/documentation/coffee/async.coffee @@ -2,14 +2,14 @@ sleep = (ms) -> new Promise (resolve) -> window.setTimeout resolve, ms +say = (text) -> + window.speechSynthesis.cancel() # cancel any prior utterances + window.speechSynthesis.speak new SpeechSynthesisUtterance text + countdown = (seconds) -> for i in [seconds..1] - if window.speechSynthesis? - utterance = new SpeechSynthesisUtterance "#{i}" - window.speechSynthesis.cancel() # cancel any prior utterances - window.speechSynthesis.speak utterance - console.log i + say "#{i}" await sleep 1000 # wait one second - alert "Done! (Check the console!)" + say "Blastoff!" countdown(3)