mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
doc fixes and updates
This commit is contained in:
4
Cakefile
4
Cakefile
@@ -184,10 +184,10 @@ task 'doc:site', 'watch and continually rebuild the documentation for the websit
|
||||
|
||||
do renderIndex = ->
|
||||
codeSnippetCounter = 0
|
||||
rendered = _.template fs.readFileSync(source, 'utf-8'),
|
||||
render = _.template fs.readFileSync(source, 'utf-8')
|
||||
fs.writeFileSync 'index.html', render
|
||||
codeFor: codeFor()
|
||||
releaseHeader: releaseHeader
|
||||
fs.writeFileSync 'index.html', rendered
|
||||
log "compiled", green, "#{source}"
|
||||
|
||||
fs.watchFile source, interval: 200, renderIndex
|
||||
|
||||
10
documentation/coffee/async.coffee
Normal file
10
documentation/coffee/async.coffee
Normal file
@@ -0,0 +1,10 @@
|
||||
concatPages = (urls) ->
|
||||
string = ""
|
||||
for url in urls
|
||||
# fetchURL returns a 'thenable' A+/Promise object
|
||||
string += await fetchURL(url)
|
||||
string
|
||||
|
||||
concatPages([page, otherPage, yetAnother])
|
||||
.then (string) ->
|
||||
console.log "Concatenation result: #{string}"
|
||||
@@ -829,7 +829,7 @@ Block
|
||||
|
||||
<p>
|
||||
<span id="fat-arrow" class="bookmark"></span>
|
||||
<b class="header">Bound Functions, Generator Functions</b>
|
||||
<b class="header">Function Modifiers</b>
|
||||
In JavaScript, the <code>this</code> keyword is dynamically scoped to mean the
|
||||
object that the current function is attached to. If you pass a function as
|
||||
a callback or attach it to a different object, the original value of <code>this</code>
|
||||
@@ -857,9 +857,9 @@ Block
|
||||
constructed.
|
||||
</p>
|
||||
<p>
|
||||
CoffeeScript functions also support
|
||||
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">ES6 generator functions</a>
|
||||
through the <code>yield</code> keyword. There's no <code>function*(){}</code>
|
||||
CoffeeScript also supports
|
||||
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">generator functions</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function">async functions</a>
|
||||
through the <code>yield</code> and <code>await</code> keywords respectively. There's no <code>function*(){}</code> or <code>async function(){}</code>
|
||||
nonsense — a generator in CoffeeScript is simply a function that yields.
|
||||
</p>
|
||||
<%= codeFor('generators', 'ps.next().value') %>
|
||||
@@ -868,6 +868,15 @@ Block
|
||||
may be used if you need to force a generator that doesn't yield.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Likewise, an async function in CoffeeScript is simply a function that awaits.
|
||||
</p>
|
||||
<%= codeFor('async') %>
|
||||
<p>
|
||||
Similar to how <code>yield return</code> forces a generator, <code>await return</code>
|
||||
may be used to force a function to be async.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span id="embedded" class="bookmark"></span>
|
||||
<b class="header">Embedded JavaScript</b>
|
||||
|
||||
Reference in New Issue
Block a user