File: async.coffee

package info (click to toggle)
coffeescript 2.7.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,608 kB
  • sloc: javascript: 1,273; makefile: 19; xml: 9; sh: 6
file content (18 lines) | stat: -rw-r--r-- 408 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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()
  window.speechSynthesis.speak new SpeechSynthesisUtterance text

countdown = (seconds) ->
  for i in [seconds..1]
    say i
    await sleep 1000 # wait one second
  say "Blastoff!"

countdown 3