1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
* Move analytics initialization into docs.coffee

* Bump Bootstrap and CodeMirror versions

* Update output

* Merge CodeMirror styles

* Update CodeMirror styles

* Better flexbox layout for docs, including flex auto-sized sidebar and main column

* Minor styling fixes for Edge

* Fix scrollspy for new layout

* Update output

* Clicking on the CoffeeScript logo in the navbar should scroll to top; fix main column width on mobile

* Update output

* 2.3.0 changelog

* Update operators section for **

* Update docs for ES2018 object rest/spread

* Remove references to Node's experimental modules support

* Move the README coffee cup to the right side, so our name isn't cut off on the NPM page; update README and CONTRIBUTING text

* Update dependencies

* Add compatibility note for async generators

* Bump version to 2.3.0 and update output

* Have CI test in Node 10 instead of 9

* Somehow this gets generated slightly differently in Node 10

* Fix #4042: Update broken link
This commit is contained in:
Geoffrey Booth 2018-04-28 18:57:15 -07:00 committed by GitHub
parent 6df8f5ff17
commit 8061ecf0e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 1840 additions and 2634 deletions

View file

@ -3,7 +3,7 @@ language: node_js
node_js: node_js:
- 6 - 6
- 8 - 8
- 9 - 10
cache: cache:
directories: directories:

View file

@ -6,4 +6,9 @@
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffeescript/tree/master/src). If youre just getting started with CoffeeScript, theres a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide). * Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffeescript/tree/master/src). If youre just getting started with CoffeeScript, theres a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide).
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffeescript.js` file. Well do those things before cutting a new release. You _should,_ however, commit the updated compiled JavaScript files in `lib`. * In your pull request, do not add documentation to `index.html` or re-build the minified `coffeescript.js` file. Well do those things before cutting a new release. You _should,_ however, commit the updated compiled JavaScript files in `lib`.
* To get started, read the guides in the wiki:
* [Hacking on the CoffeeScript Compiler](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-Hacking-on-the-CoffeeScript-Compiler)
* [How parsing works](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-How-parsing-works)
* [Update the docs](https://github.com/jashkenas/coffeescript/wiki/%5BHowTo%5D-Update-the-docs)

View file

@ -1,27 +1,27 @@
@@@@@@@ @@@@ @@@@@ @@@@@@@ @@@@ @@@@@
{ @@@@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@ @@@ {
} } { @@@@ @@ @@@ @@@ @@@@ @@ @@@ @@@ } } {
{ { } } @@@@ @@@@@@@ @@@ @@@ @@@@@@ @@@@@@ @@@@ @@@@@@@ @@@ @@@ @@@@@@ @@@@@@ { { } }
} }{ { @@@@ @@@ @@ @@@@@ @@@@@@ @@@ @@ @@@@ @@ @@@@ @@@ @@ @@@@@ @@@@@@ @@@ @@ @@@@ @@ } }{ {
{ }{ } } @@@@ @@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@ @@@@ @@ @@@ @@@ @@@ @@@ @@@ @@@ { }{ } }
{ }{ }{ { } @@@@ @@@@ @@ @@@ @@@ @@@@@@@@ @@@@@@@@ @@@@ @@@@ @@ @@@ @@@ @@@@@@@@ @@@@@@@@ { }{ }{ { }
{ { } { } { } } @@@@@ @@@@ @@ @@@ @@@ @@@ @@@ @@@@@ @@@@ @@ @@@ @@@ @@@ @@@ { { } { } { } }
{ } { } { } @@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ @@@@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ { } { } { }
@@@@@@ { } { } @@@@@@@ @@@@@ @@@ @@@ @@@@@ @@@@@ @@@@@ @@@ @@@ @@@@@ @@@@@ @@@@@@ { } { } @@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@ @@@ @@@ @@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@ @@@ @@@ @@@@@@ @@@ @@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@
@@ @@@@@@@@@@@@@@@@@@@@@@@@ @@@@ @@ @@@ @@@@ @@@@ @@ @@@ @@@@ @@ @@@@@@@@@@@@@@@@@@@@@@@@
@@@ @@@@@@@@@@@@@@@@@@@@@ @@@@ @@@ @@ @@@@ @@@@ @@@ @@ @@@@ @@@ @@@@@@@@@@@@@@@@@@@@@
@@@ @@@@@@@@@@@@@@@@@@ @@@@@ @@@@@ @@ @@ @@@ @@@@@@@ @@@@@ @@@@@ @@@@@ @@ @@ @@@ @@@@@@@ @@@@@ @@@ @@@@@@@@@@@@@@@@@@
@@@ @@@@@@@@@@@@@@@@ @@@@@ @@@ @@@ @@@@@@@@ @@@@ @@@@ @@@@@@@ @@@@@ @@@ @@@ @@@@@@@@ @@@@ @@@@ @@@@@@@ @@@ @@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@ @@@@@ @@@ @@@@ @@@@ @@@ @@@ @@@ @@@@@ @@@ @@@@ @@@@ @@@ @@@ @@@ @@@@@@@@@@@@@@
@@@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
@@@ @@@@ @@@ @@@@ @@@@ @@@ @@@@ @@@@ @@@ @@@@ @@@ @@@@ @@@@ @@@ @@@@ @@@@
@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@ @@@@
@@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@@@@@@ @@@@ @@@@@@@@@ @@@@@@ @@@@ @@@@ @@@@@@@@@ @@@@
@@@ @@@@ @@@ @@@@
@@@ @@@
@@@ @@@
CoffeeScript is a little language that compiles into JavaScript. CoffeeScript is a little language that compiles into JavaScript.
@ -30,11 +30,13 @@ CoffeeScript is a little language that compiles into JavaScript.
Once you have Node.js installed: Once you have Node.js installed:
```shell ```shell
# Install locally for a project:
npm install --save-dev coffeescript
# Install globally to execute .coffee files anywhere:
npm install --global coffeescript npm install --global coffeescript
``` ```
Leave off the `--global` if you dont wish to install globally.
## Getting Started ## Getting Started
Execute a script: Execute a script:

View file

@ -2,7 +2,7 @@ environment:
matrix: matrix:
- nodejs_version: '6' - nodejs_version: '6'
- nodejs_version: '8' - nodejs_version: '8'
- nodejs_version: '9' - nodejs_version: '10'
- nodejs_version: '' # Installs latest. - nodejs_version: '' # Installs latest.
install: install:

View file

@ -580,11 +580,11 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
o <span class="hljs-string">'Identifier'</span> o <span class="hljs-string">'Identifier'</span>
o <span class="hljs-string">'Property'</span> o <span class="hljs-string">'Property'</span>
o <span class="hljs-string">'ThisProperty'</span> o <span class="hljs-string">'ThisProperty'</span>
o <span class="hljs-string">'[ Expression ]'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> ComputedPropertyName $<span class="hljs-number">2</span>
] ]
ObjAssignable: [ ObjAssignable: [
o <span class="hljs-string">'SimpleObjAssignable'</span> o <span class="hljs-string">'SimpleObjAssignable'</span>
o <span class="hljs-string">'[ Expression ]'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> ComputedPropertyName $<span class="hljs-number">2</span>
o <span class="hljs-string">'AlphaNumeric'</span> o <span class="hljs-string">'AlphaNumeric'</span>
]</pre></div></div> ]</pre></div></div>
@ -1492,26 +1492,31 @@ or postfix, with a single expression.</p>
</div> </div>
<div class="content"><div class='highlight'><pre> For: [ <div class="content"><div class='highlight'><pre> For: [
o <span class="hljs-string">'Statement ForBody'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> For $<span class="hljs-number">1</span>, $<span class="hljs-number">2</span> o <span class="hljs-string">'Statement ForBody'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">2.</span>addBody $<span class="hljs-number">1</span>
o <span class="hljs-string">'Expression ForBody'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> For $<span class="hljs-number">1</span>, $<span class="hljs-number">2</span> o <span class="hljs-string">'Expression ForBody'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">2.</span>addBody $<span class="hljs-number">1</span>
o <span class="hljs-string">'ForBody Block'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> For $<span class="hljs-number">2</span>, $<span class="hljs-number">1</span> o <span class="hljs-string">'ForBody Block'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">1.</span>addBody $<span class="hljs-number">2</span>
o <span class="hljs-string">'ForLineBody Block'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> For $<span class="hljs-number">2</span>, $<span class="hljs-number">1</span> o <span class="hljs-string">'ForLineBody Block'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">1.</span>addBody $<span class="hljs-number">2</span>
] ]
ForBody: [ ForBody: [
o <span class="hljs-string">'FOR Range'</span>, <span class="hljs-function">-&gt;</span> source: (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Value($<span class="hljs-number">2</span>)) o <span class="hljs-string">'FOR Range'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> For [], source: (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Value($<span class="hljs-number">2</span>))
o <span class="hljs-string">'FOR Range BY Expression'</span>, <span class="hljs-function">-&gt;</span> source: (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Value($<span class="hljs-number">2</span>)), step: $<span class="hljs-number">4</span> o <span class="hljs-string">'FOR Range BY Expression'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> For [], source: (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Value($<span class="hljs-number">2</span>)), step: $<span class="hljs-number">4</span>
o <span class="hljs-string">'ForStart ForSource'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">2.</span>own = $<span class="hljs-number">1.</span>own; $<span class="hljs-number">2.</span>ownTag = $<span class="hljs-number">1.</span>ownTag; $<span class="hljs-number">2.</span>name = $<span class="hljs-number">1</span>[<span class="hljs-number">0</span>]; $<span class="hljs-number">2.</span>index = $<span class="hljs-number">1</span>[<span class="hljs-number">1</span>]; $<span class="hljs-number">2</span> o <span class="hljs-string">'ForStart ForSource'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">1.</span>addSource $<span class="hljs-number">2</span>
] ]
ForLineBody: [ ForLineBody: [
o <span class="hljs-string">'FOR Range BY ExpressionLine'</span>, <span class="hljs-function">-&gt;</span> source: (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Value($<span class="hljs-number">2</span>)), step: $<span class="hljs-number">4</span> o <span class="hljs-string">'FOR Range BY ExpressionLine'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> For [], source: (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Value($<span class="hljs-number">2</span>)), step: $<span class="hljs-number">4</span>
o <span class="hljs-string">'ForStart ForLineSource'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">2.</span>own = $<span class="hljs-number">1.</span>own; $<span class="hljs-number">2.</span>ownTag = $<span class="hljs-number">1.</span>ownTag; $<span class="hljs-number">2.</span>name = $<span class="hljs-number">1</span>[<span class="hljs-number">0</span>]; $<span class="hljs-number">2.</span>index = $<span class="hljs-number">1</span>[<span class="hljs-number">1</span>]; $<span class="hljs-number">2</span> o <span class="hljs-string">'ForStart ForLineSource'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">1.</span>addSource $<span class="hljs-number">2</span>
] ]
ForStart: [ ForStart: [
o <span class="hljs-string">'FOR ForVariables'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">2</span> o <span class="hljs-string">'FOR ForVariables'</span>, <span class="hljs-function">-&gt;</span> <span class="hljs-keyword">new</span> For [], name: $<span class="hljs-number">2</span>[<span class="hljs-number">0</span>], index: $<span class="hljs-number">2</span>[<span class="hljs-number">1</span>]
o <span class="hljs-string">'FOR OWN ForVariables'</span>, <span class="hljs-function">-&gt;</span> $<span class="hljs-number">3.</span>own = <span class="hljs-literal">yes</span>; $<span class="hljs-number">3.</span>ownTag = (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Literal($<span class="hljs-number">2</span>)); $<span class="hljs-number">3</span> o <span class="hljs-string">'FOR AWAIT ForVariables'</span>, <span class="hljs-function">-&gt;</span>
[name, index] = $<span class="hljs-number">3</span>
<span class="hljs-keyword">new</span> For [], {name, index, await: <span class="hljs-literal">yes</span>, awaitTag: (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Literal($<span class="hljs-number">2</span>))}
o <span class="hljs-string">'FOR OWN ForVariables'</span>, <span class="hljs-function">-&gt;</span>
[name, index] = $<span class="hljs-number">3</span>
<span class="hljs-keyword">new</span> For [], {name, index, own: <span class="hljs-literal">yes</span>, ownTag: (LOC(<span class="hljs-number">2</span>) <span class="hljs-keyword">new</span> Literal($<span class="hljs-number">2</span>))}
]</pre></div></div> ]</pre></div></div>
</li> </li>

View file

@ -2579,7 +2579,7 @@ HEREDOC_INDENT = <span class="hljs-regexp">/\n+([^\n\S]*)(?=\S)/g</span></pr
///</span> ///</span>
REGEX_FLAGS = <span class="hljs-regexp">/^\w*/</span> REGEX_FLAGS = <span class="hljs-regexp">/^\w*/</span>
VALID_FLAGS = <span class="hljs-regexp">/^(?!.*(.).*\1)[imguy]*$/</span> VALID_FLAGS = <span class="hljs-regexp">/^(?!.*(.).*\1)[gimsuy]*$/</span>
HEREGEX = <span class="hljs-regexp">/// ^ HEREGEX = <span class="hljs-regexp">/// ^
(?: (?:

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -692,7 +692,7 @@ textarea {
<section id="overview"> <section id="overview">
<p><strong>CoffeeScript is a little language that compiles into JavaScript.</strong> Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.</p> <p><strong>CoffeeScript is a little language that compiles into JavaScript.</strong> Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.</p>
<p>The golden rule of CoffeeScript is: <em>“Its just JavaScript.”</em> The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.</p> <p>The golden rule of CoffeeScript is: <em>“Its just JavaScript.”</em> The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable, pretty-printed, and tends to run as fast or faster than the equivalent handwritten JavaScript.</p>
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.2.4">2.2.4</a></p> <p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.3.0">2.3.0</a></p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash"><span class="comment"># Install locally for a project:</span> <blockquote class="uneditable-code-block"><pre><code class="language-bash"><span class="comment"># Install locally for a project:</span>
npm install --save-dev coffeescript npm install --save-dev coffeescript
@ -896,6 +896,7 @@ cubes = (function() {
<li><a href="#modules">Modules</a> and <a href="#jsx">JSX</a> always require transpilation.</li> <li><a href="#modules">Modules</a> and <a href="#jsx">JSX</a> always require transpilation.</li>
<li><a href="http://coffeescript.org/#splats">Splats, a.k.a. object rest/spread syntax, for objects</a> are supported by Node 8.6+.</li> <li><a href="http://coffeescript.org/#splats">Splats, a.k.a. object rest/spread syntax, for objects</a> are supported by Node 8.6+.</li>
<li>The <a href="https://github.com/tc39/proposal-regexp-dotall-flag">regular expression <code>s</code> (dotall) flag</a> is supported by Node 9+.</li> <li>The <a href="https://github.com/tc39/proposal-regexp-dotall-flag">regular expression <code>s</code> (dotall) flag</a> is supported by Node 9+.</li>
<li><a href="https://github.com/tc39/proposal-async-iteration">Async generator functions</a> are supported by Node 10+.</li>
</ul> </ul>
<p>This list may be incomplete, and excludes versions of Node that support newer features behind flags; please refer to <a href="http://node.green/">node.green</a> for full details. You can <a href="test.html">run the tests in your browser</a> to see what your browser supports. It is your responsibility to ensure that your runtime supports the modern features you use; or that you <a href="#transpilation">transpile</a> your code. When in doubt, transpile.</p> <p>This list may be incomplete, and excludes versions of Node that support newer features behind flags; please refer to <a href="http://node.green/">node.green</a> for full details. You can <a href="test.html">run the tests in your browser</a> to see what your browser supports. It is your responsibility to ensure that your runtime supports the modern features you use; or that you <a href="#transpilation">transpile</a> your code. When in doubt, transpile.</p>
@ -1834,7 +1835,7 @@ currentUser = {
</div> </div>
</aside> </aside>
<p>In ECMAScript this is called <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator">spread syntax</a>, and has been supported for arrays since ES2015 but is <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Spread_in_object_literals">coming soon for objects</a>. Until object spread syntax is officially supported, the CoffeeScript compiler outputs the same polyfill as <a href="https://babeljs.io/docs/plugins/transform-object-rest-spread/">Babels rest spread transform</a>; but once it is supported, we will revise the compilers output. Note that there are <a href="https://developers.google.com/web/updates/2017/06/object-rest-spread">very subtle differences</a> between the polyfill and the current proposal.</p> <p>In ECMAScript this is called <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator">spread syntax</a>, and has been supported for arrays since ES2015 and objects since ES2018.</p>
</section> </section>
<section id="loops"> <section id="loops">
@ -2633,7 +2634,7 @@ tabs.selectTabAtIndex(modulo(tabs.currentIndex - count, tabs.length));
</tr> </tr>
<tr> <tr>
<td><code>a ** b</code></td> <td><code>a ** b</code></td>
<td><code>Math.pow(a, b)</code></td> <td><code>a ** b</code></td>
</tr> </tr>
<tr> <tr>
<td><code>a // b</code></td> <td><code>a // b</code></td>
@ -3278,7 +3279,7 @@ tim = new Person({
</section> </section>
<section id="fat-arrow"> <section id="fat-arrow">
<h2>Bound (Fat Arrow) Functions</h2> <h2>Bound (Fat Arrow) Functions</h2>
<p>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> will be lost. If youre not familiar with this behavior, <a href="http://64.13.255.16/articles/scope_in_javascript/">this Digital Web article</a> gives a good overview of the quirks.</p> <p>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> will be lost. If youre not familiar with this behavior, <a href="https://web.archive.org/web/20150316122013/http://www.digital-web.com/articles/scope_in_javascript">this Digital Web article</a> gives a good overview of the quirks.</p>
<p>The fat arrow <code>=&gt;</code> can be used to both define a function, and to bind it to the current value of <code>this</code>, right on the spot. This is helpful when using callback-based libraries like Prototype or jQuery, for creating iterator functions to pass to <code>each</code>, or event-handler functions to use with <code>on</code>. Functions created with the fat arrow are able to access properties of the <code>this</code> where theyre defined.</p> <p>The fat arrow <code>=&gt;</code> can be used to both define a function, and to bind it to the current value of <code>this</code>, right on the spot. This is helpful when using callback-based libraries like Prototype or jQuery, for creating iterator functions to pass to <code>each</code>, or event-handler functions to use with <code>on</code>. Functions created with the fat arrow are able to access properties of the <code>this</code> where theyre defined.</p>
<aside class="code-example container-fluid bg-ribbed-dark" data-example="fat_arrow"> <aside class="code-example container-fluid bg-ribbed-dark" data-example="fat_arrow">
<div class="row"> <div class="row">
@ -4841,7 +4842,7 @@ The CoffeeScript logo is available in SVG for use in presentations.</li>
</section> </section>
<section id="annotated-source"> <section id="annotated-source">
<h2>Annotated Source</h2> <h2>Annotated Source</h2>
<p>You can browse the CoffeeScript 2.2.4 source in readable, annotated form <a href="annotated-source/">here</a>. You can also jump directly to a particular source file:</p> <p>You can browse the CoffeeScript 2.3.0 source in readable, annotated form <a href="annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
<ul> <ul>
<li><a href="annotated-source/grammar.html">Grammar Rules — src/grammar</a></li> <li><a href="annotated-source/grammar.html">Grammar Rules — src/grammar</a></li>
<li><a href="annotated-source/lexer.html">Lexing Tokens — src/lexer</a></li> <li><a href="annotated-source/lexer.html">Lexing Tokens — src/lexer</a></li>
@ -5518,6 +5519,17 @@ x = <span class="number">2</span> + <span class="number">2</span>
</section> </section>
<section id="changelog"> <section id="changelog">
<h2>Changelog</h2> <h2>Changelog</h2>
<div class="anchor" id="2.3.0"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/2.2.4...2.3.0">2.3.0</a>
<span class="timestamp"> &mdash; <time datetime="2018-04-29">April 29, 2018</time></span>
</h2><ul>
<li>This release adds support for all the new features and syntaxes in ES2018 that werent already possible in CoffeeScript. For all of the below features, make sure that you <a href="#transpilation">transpile</a> unless you know that your target runtime(s) support each feature.</li>
<li>Asynchronous iterators are now supported. You can now <code>yield</code> an <code>await</code> call, e.g. <code>do -&gt; until file.EOF then yield await file.readLine()</code>.</li>
<li>Object splats/destructuring, a.k.a. object rest/spread syntax, has been standardized as part of ES2018 and therefore this release removes the polyfill that had previously been supporting this syntax. Code like <code>{a, b, rest...} = obj</code> now outputs more or less just like it appears, rather than being converted into an <code>Object.assign</code> call. Note that there are <a href="https://developers.google.com/web/updates/2017/06/object-rest-spread">some subtle differences</a> between the <code>Object.assign</code> polyfill and the native implementation.</li>
<li>The exponentiation operator, <code>**</code>, and exponentiation assignment operator <code>**=</code> are new to JavaScript in ES2018. Now code like <code>a ** 3</code> is output as it appears, rather than being converted into <code>Math.pow(a, 3)</code> as it was before.</li>
<li>The <code>s</code> (dotAll) flag is now supported in regular expressions.</li>
</ul>
<div class="anchor" id="2.2.4"></div> <div class="anchor" id="2.2.4"></div>
<h2 class="header"> <h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/2.2.3...2.2.4">2.2.4</a> <a href="https://github.com/jashkenas/coffeescript/compare/2.2.3...2.2.4">2.2.4</a>

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,14 @@
## Changelog ## Changelog
```
releaseHeader('2018-04-29', '2.3.0', '2.2.4')
```
* This release adds support for all the new features and syntaxes in ES2018 that werent already possible in CoffeeScript. For all of the below features, make sure that you [transpile](#transpilation) unless you know that your target runtime(s) support each feature.
* Asynchronous iterators are now supported. You can now `yield` an `await` call, e.g. `do -> until file.EOF then yield await file.readLine()`.
* Object splats/destructuring, a.k.a. object rest/spread syntax, has been standardized as part of ES2018 and therefore this release removes the polyfill that had previously been supporting this syntax. Code like `{a, b, rest...} = obj` now outputs more or less just like it appears, rather than being converted into an `Object.assign` call. Note that there are [some subtle differences](https://developers.google.com/web/updates/2017/06/object-rest-spread) between the `Object.assign` polyfill and the native implementation.
* The exponentiation operator, `**`, and exponentiation assignment operator `**=` are new to JavaScript in ES2018. Now code like `a ** 3` is output as it appears, rather than being converted into `Math.pow(a, 3)` as it was before.
* The `s` (dotAll) flag is now supported in regular expressions.
``` ```
releaseHeader('2018-03-29', '2.2.4', '2.2.3') releaseHeader('2018-03-29', '2.2.4', '2.2.3')
``` ```

View file

@ -5,5 +5,6 @@ Most modern JavaScript features that CoffeeScript supports can run natively in N
* [Modules](#modules) and [JSX](#jsx) always require transpilation. * [Modules](#modules) and [JSX](#jsx) always require transpilation.
* [Splats, a.k.a. object rest/spread syntax, for objects](http://coffeescript.org/#splats) are supported by Node 8.6+. * [Splats, a.k.a. object rest/spread syntax, for objects](http://coffeescript.org/#splats) are supported by Node 8.6+.
* The [regular expression `s` (dotall) flag](https://github.com/tc39/proposal-regexp-dotall-flag) is supported by Node 9+. * The [regular expression `s` (dotall) flag](https://github.com/tc39/proposal-regexp-dotall-flag) is supported by Node 9+.
* [Async generator functions](https://github.com/tc39/proposal-async-iteration) are supported by Node 10+.
This list may be incomplete, and excludes versions of Node that support newer features behind flags; please refer to [node.green](http://node.green/) for full details. You can [run the tests in your browser](test.html) to see what your browser supports. It is your responsibility to ensure that your runtime supports the modern features you use; or that you [transpile](#transpilation) your code. When in doubt, transpile. This list may be incomplete, and excludes versions of Node that support newer features behind flags; please refer to [node.green](http://node.green/) for full details. You can [run the tests in your browser](test.html) to see what your browser supports. It is your responsibility to ensure that your runtime supports the modern features you use; or that you [transpile](#transpilation) your code. When in doubt, transpile.

View file

@ -1,6 +1,6 @@
## Bound (Fat Arrow) Functions ## Bound (Fat Arrow) Functions
In JavaScript, the `this` 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 `this` will be lost. If youre not familiar with this behavior, [this Digital Web article](http://64.13.255.16/articles/scope_in_javascript/) gives a good overview of the quirks. In JavaScript, the `this` 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 `this` will be lost. If youre not familiar with this behavior, [this Digital Web article](https://web.archive.org/web/20150316122013/http://www.digital-web.com/articles/scope_in_javascript) gives a good overview of the quirks.
The fat arrow `=>` can be used to both define a function, and to bind it to the current value of `this`, right on the spot. This is helpful when using callback-based libraries like Prototype or jQuery, for creating iterator functions to pass to `each`, or event-handler functions to use with `on`. Functions created with the fat arrow are able to access properties of the `this` where theyre defined. The fat arrow `=>` can be used to both define a function, and to bind it to the current value of `this`, right on the spot. This is helpful when using callback-based libraries like Prototype or jQuery, for creating iterator functions to pass to `each`, or event-handler functions to use with `on`. Functions created with the fat arrow are able to access properties of the `this` where theyre defined.

View file

@ -39,7 +39,7 @@ All together now:
| `a in b` | `[].indexOf.call(b, a) >= 0` | | `a in b` | `[].indexOf.call(b, a) >= 0` |
| `a of b` | `a in b` | | `a of b` | `a in b` |
| `for a from b` | `for (a of b)` | | `for a from b` | `for (a of b)` |
| `a ** b` | `Math.pow(a, b)` | | `a ** b` | `a ** b` |
| `a // b` | `Math.floor(a / b)` | | `a // b` | `Math.floor(a / b)` |
| `a %% b` | `(a % b + b) % b` | | `a %% b` | `(a % b + b) % b` |

View file

@ -22,4 +22,4 @@ codeFor('array_spread', 'all')
codeFor('object_spread', 'JSON.stringify(currentUser)') codeFor('object_spread', 'JSON.stringify(currentUser)')
``` ```
In ECMAScript this is called [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator), and has been supported for arrays since ES2015 but is [coming soon for objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Spread_in_object_literals). Until object spread syntax is officially supported, the CoffeeScript compiler outputs the same polyfill as [Babels rest spread transform](https://babeljs.io/docs/plugins/transform-object-rest-spread/); but once it is supported, we will revise the compilers output. Note that there are [very subtle differences](https://developers.google.com/web/updates/2017/06/object-rest-spread) between the polyfill and the current proposal. In ECMAScript this is called [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator), and has been supported for arrays since ES2015 and objects since ES2018.

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// This **Browser** compatibility layer extends core CoffeeScript functions // This **Browser** compatibility layer extends core CoffeeScript functions
// to make things work smoothly when compiling code directly in the browser. // to make things work smoothly when compiling code directly in the browser.

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// `cake` is a simplified version of [Make](http://www.gnu.org/software/make/) // `cake` is a simplified version of [Make](http://www.gnu.org/software/make/)
// ([Rake](http://rake.rubyforge.org/), [Jake](https://github.com/280north/jake)) // ([Rake](http://rake.rubyforge.org/), [Jake](https://github.com/280north/jake))

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// CoffeeScript can be used both on the server, as a command-line compiler based // CoffeeScript can be used both on the server, as a command-line compiler based
// on Node.js/V8, or to run CoffeeScript directly in the browser. This module // on Node.js/V8, or to run CoffeeScript directly in the browser. This module

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// The `coffee` utility. Handles command-line compilation of CoffeeScript // The `coffee` utility. Handles command-line compilation of CoffeeScript
// into various forms: saved into `.js` files or printed to stdout // into various forms: saved into `.js` files or printed to stdout

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// The CoffeeScript parser is generated by [Jison](https://github.com/zaach/jison) // The CoffeeScript parser is generated by [Jison](https://github.com/zaach/jison)
// from this grammar file. Jison is a bottom-up parser generator, similar in // from this grammar file. Jison is a bottom-up parser generator, similar in

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// This file contains the common helper functions that we'd like to share among // This file contains the common helper functions that we'd like to share among
// the **Lexer**, **Rewriter**, and the **Nodes**. Merge objects, flatten // the **Lexer**, **Rewriter**, and the **Nodes**. Merge objects, flatten

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// Node.js Implementation // Node.js Implementation
var CoffeeScript, ext, fs, helpers, i, len, path, ref, universalCompile, vm, var CoffeeScript, ext, fs, helpers, i, len, path, ref, universalCompile, vm,

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// The CoffeeScript Lexer. Uses a series of token-matching regexes to attempt // The CoffeeScript Lexer. Uses a series of token-matching regexes to attempt
// matches against the beginning of the source code. When a match is found, // matches against the beginning of the source code. When a match is found,

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// `nodes.coffee` contains all of the node classes for the syntax tree. Most // `nodes.coffee` contains all of the node classes for the syntax tree. Most
// nodes are created as the result of actions in the [grammar](grammar.html), // nodes are created as the result of actions in the [grammar](grammar.html),

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat, var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat,
splice = [].splice; splice = [].splice;

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, getRootModule, helpers, i, len, loadFile, path, ref; var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, getRootModule, helpers, i, len, loadFile, path, ref;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, runInContext, sawSIGINT, transpile, updateSyntaxError, vm; var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, runInContext, sawSIGINT, transpile, updateSyntaxError, vm;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// The CoffeeScript language has a good deal of optional syntax, implicit syntax, // The CoffeeScript language has a good deal of optional syntax, implicit syntax,
// and shorthand syntax. This can greatly complicate a grammar and bloat // and shorthand syntax. This can greatly complicate a grammar and bloat

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// The **Scope** class regulates lexical scoping within CoffeeScript. As you // The **Scope** class regulates lexical scoping within CoffeeScript. As you
// generate code, you create a tree of scopes in the same shape as the nested // generate code, you create a tree of scopes in the same shape as the nested

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.2.4 // Generated by CoffeeScript 2.3.0
(function() { (function() {
// Source maps allow JavaScript runtimes to match running JavaScript back to // Source maps allow JavaScript runtimes to match running JavaScript back to
// the original source code that corresponds to it. This can be minified // the original source code that corresponds to it. This can be minified

2053
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@
"compiler" "compiler"
], ],
"author": "Jeremy Ashkenas", "author": "Jeremy Ashkenas",
"version": "2.2.4", "version": "2.3.0",
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=6" "node": ">=6"
@ -39,17 +39,17 @@
"url": "git://github.com/jashkenas/coffeescript.git" "url": "git://github.com/jashkenas/coffeescript.git"
}, },
"devDependencies": { "devDependencies": {
"babel-core": "~6.26.0", "babel-core": "~6.26.2",
"babel-preset-babili": "~0.1.4", "babel-preset-babili": "~0.1.4",
"babel-preset-env": "~1.6.1", "babel-preset-env": "~1.6.1",
"babel-preset-minify": "^0.3.0", "babel-preset-minify": "^0.4.0",
"codemirror": "^5.35.0", "codemirror": "^5.37.0",
"docco": "~0.8.0", "docco": "~0.8.0",
"highlight.js": "~9.12.0", "highlight.js": "~9.12.0",
"jison": ">=0.4.18", "jison": ">=0.4.18",
"markdown-it": "~8.4.1", "markdown-it": "~8.4.1",
"underscore": "~1.8.3", "underscore": "~1.9.0",
"webpack": "~4.1.1" "webpack": "~4.6.0"
}, },
"dependencies": {} "dependencies": {}
} }