[CS2] Fix links in v2 docs (#4506)

* Update 2.0.0-beta1 docs

* Fix broken links, update redirected links

* Rebuild v2 docs with updated links

* A few more fixed links
This commit is contained in:
Geoffrey Booth 2017-04-17 19:43:22 -07:00 committed by GitHub
parent db216ec384
commit d7e096aeee
33 changed files with 157 additions and 147 deletions

View File

@ -46,7 +46,7 @@ coffee -c /path/to/script.coffee
For documentation, usage, and examples, see: http://coffeescript.org/
To suggest a feature or report a bug: http://github.com/jashkenas/coffeescript/issues
To suggest a feature or report a bug: https://github.com/jashkenas/coffeescript/issues
If youd like to chat, drop by #coffeescript on Freenode IRC.
@ -54,4 +54,4 @@ The source repository: https://github.com/jashkenas/coffeescript.git
Changelog: http://coffeescript.org/#changelog
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors
Our lovely and talented contributors are listed here: https://github.com/jashkenas/coffeescript/contributors

View File

@ -116,7 +116,7 @@
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p><code>cake</code> is a simplified version of <a href="http://www.gnu.org/software/make/">Make</a>
(<a href="http://rake.rubyforge.org/">Rake</a>, <a href="http://github.com/280north/jake">Jake</a>)
(<a href="http://rake.rubyforge.org/">Rake</a>, <a href="https://github.com/280north/jake">Jake</a>)
for CoffeeScript. You define tasks with names and descriptions in a Cakefile,
and can call them from the command line, or invoke them from other tasks.</p>
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the

View File

@ -115,17 +115,17 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>The CoffeeScript parser is generated by <a href="http://github.com/zaach/jison">Jison</a>
<p>The CoffeeScript parser is generated by <a href="https://github.com/zaach/jison">Jison</a>
from this grammar file. Jison is a bottom-up parser generator, similar in
style to <a href="http://www.gnu.org/software/bison">Bison</a>, implemented in JavaScript.
It can recognize <a href="http://en.wikipedia.org/wiki/LR_grammar">LALR(1), LR(0), SLR(1), and LR(1)</a>
It can recognize <a href="https://en.wikipedia.org/wiki/LR_grammar">LALR(1), LR(0), SLR(1), and LR(1)</a>
type grammars. To create the Jison parser, we list the pattern to match
on the left-hand side, and the action to take (usually the creation of syntax
tree nodes) on the right. As the parser runs, it
shifts tokens from our token stream, from left to right, and
<a href="http://en.wikipedia.org/wiki/Bottom-up_parsing">attempts to match</a>
<a href="https://en.wikipedia.org/wiki/Bottom-up_parsing">attempts to match</a>
the token sequence against the rules below. When a match can be made, it
reduces into the <a href="http://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols">nonterminal</a>
reduces into the <a href="https://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols">nonterminal</a>
(the enclosing name at the top), and we proceed from there.</p>
<p>If you run the <code>cake build:parser</code> command, Jison constructs a parse table
from our rules and saves it into <code>lib/parser.js</code>.</p>
@ -199,7 +199,7 @@ wrapper and just returning the value directly.</p>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Our handy DSL for Jison grammar generation, thanks to
<a href="http://github.com/creationix">Tim Caswell</a>. For every rule in the grammar,
<a href="https://github.com/creationix">Tim Caswell</a>. For every rule in the grammar,
we pass the pattern-defining string, the action to run, and extra options,
optionally. If no action is specified, we simply pass the value of the
previous nonterminal.</p>

View File

@ -121,7 +121,7 @@ a token is produced, we consume the match, and start again. Tokens are in the
form:</p>
<pre><code>[tag, value, locationData]
</code></pre><p>where locationData is {first_line, first_column, last_line, last_column}, which is a
format that can be fed directly into <a href="http://github.com/zaach/jison">Jison</a>. These
format that can be fed directly into <a href="https://github.com/zaach/jison">Jison</a>. These
are read by jison in the <code>parser.lexer</code> function defined in coffee-script.coffee.</p>
</div>

View File

@ -3941,7 +3941,7 @@ CoffeeScript operations into their JavaScript equivalents.</p>
<a class="pilcrow" href="#section-155">&#182;</a>
</div>
<p>Am I capable of
<a href="http://docs.python.org/reference/expressions.html#notin">Python-style comparison chaining</a>?</p>
<a href="https://docs.python.org/3/reference/expressions.html#not-in">Python-style comparison chaining</a>?</p>
</div>

View File

@ -406,7 +406,7 @@ column for the current line:</p>
</div>
<p>Note that SourceMap VLQ encoding is “backwards”. MIDI-style VLQ encoding puts
the most-significant-bit (MSB) from the original value into the MSB of the VLQ
encoded value (see <a href="http://en.wikipedia.org/wiki/File:Uintvar_coding.svg">Wikipedia</a>).
encoded value (see <a href="https://en.wikipedia.org/wiki/File:Uintvar_coding.svg">Wikipedia</a>).
SourceMap VLQ does things the other way around, with the least significat four
bits of the original value encoded into the first byte of the VLQ encoded value.</p>

View File

@ -591,18 +591,18 @@ pre .xml .cdata {
Annotated Source
</div>
<div class="contents menu">
<a href="v1/annotated-source/grammar.html">Grammar Rules — src/grammar</a>
<a href="v1/annotated-source/lexer.html">Lexing Tokens — src/lexer</a>
<a href="v1/annotated-source/rewriter.html">The Rewriter — src/rewriter</a>
<a href="v1/annotated-source/nodes.html">The Syntax Tree — src/nodes</a>
<a href="v1/annotated-source/scope.html">Lexical Scope — src/scope</a>
<a href="v1/annotated-source/helpers.html">Helpers &amp; Utility Functions — src/helpers</a>
<a href="v1/annotated-source/coffee-script.html">The CoffeeScript Module — src/coffee-script</a>
<a href="v1/annotated-source/cake.html">Cake &amp; Cakefiles — src/cake</a>
<a href="v1/annotated-source/command.html">“coffee” Command-Line Utility — src/command</a>
<a href="v1/annotated-source/optparse.html">Option Parsing — src/optparse</a>
<a href="v1/annotated-source/repl.html">Interactive REPL — src/repl</a>
<a href="v1/annotated-source/sourcemap.html">Source Maps — src/sourcemap</a>
<a href="/v1/annotated-source/grammar.html">Grammar Rules — src/grammar</a>
<a href="/v1/annotated-source/lexer.html">Lexing Tokens — src/lexer</a>
<a href="/v1/annotated-source/rewriter.html">The Rewriter — src/rewriter</a>
<a href="/v1/annotated-source/nodes.html">The Syntax Tree — src/nodes</a>
<a href="/v1/annotated-source/scope.html">Lexical Scope — src/scope</a>
<a href="/v1/annotated-source/helpers.html">Helpers &amp; Utility Functions — src/helpers</a>
<a href="/v1/annotated-source/coffee-script.html">The CoffeeScript Module — src/coffee-script</a>
<a href="/v1/annotated-source/cake.html">Cake &amp; Cakefiles — src/cake</a>
<a href="/v1/annotated-source/command.html">“coffee” Command-Line Utility — src/command</a>
<a href="/v1/annotated-source/optparse.html">Option Parsing — src/optparse</a>
<a href="/v1/annotated-source/repl.html">Interactive REPL — src/repl</a>
<a href="/v1/annotated-source/sourcemap.html">Source Maps — src/sourcemap</a>
</div>
</div>
</div>
@ -612,7 +612,7 @@ pre .xml .cdata {
<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 CoffeeScript compiler goes to great lengths to generate output JavaScript that runs in every JavaScript runtime, but there are exceptions. Use <a href="#generator-functions">generator functions</a>, <a href="#generator-iteration"><code>for…from</code></a>, or <a href="#tagged-template-literals">tagged template literals</a> only if you know that your <a href="http://kangax.github.io/compat-table/es6/">target runtimes can support them</a>. If you use <a href="#modules">modules</a>, you will need to <a href="#modules-note">use an additional tool to resolve them</a>.</p>
<p><strong>Latest Version:</strong> <a href="http://github.com/jashkenas/coffeescript/tarball/1.12.5">1.12.5</a></p>
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/1.12.5">1.12.5</a></p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install -g coffee-script
</code></pre>
</blockquote><p><strong>CoffeeScript 2 is coming!</strong> It adds support for <a href="/v2/#classes">ES2015 classes</a>, <a href="/v2/#fat-arrow"><code>async</code>/<code>await</code></a>, and generates JavaScript using ES2015+ syntax. <a href="/v2/">Learn more</a>.</p></p>
@ -738,8 +738,8 @@ cubes = (function() {
;alert(cubes);">run: cubes</div><br class='clear' /></div>
<span class="bookmark" id="installation"></span>
<h2>Installation</h2>
<p>The command-line version of <code>coffee</code> is available as a <a href="http://nodejs.org/">Node.js</a> utility. The <a href="v1/browser-compiler/coffee-script.js">core compiler</a> however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see <a href="#try">Try CoffeeScript</a>).</p>
<p>To install, first make sure you have a working copy of the latest stable version of <a href="http://nodejs.org/">Node.js</a>. You can then install CoffeeScript globally with <a href="http://npmjs.org">npm</a>:</p>
<p>The command-line version of <code>coffee</code> is available as a <a href="https://nodejs.org/">Node.js</a> utility. The <a href="/v1/browser-compiler/coffee-script.js">core compiler</a> however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see <a href="#try">Try CoffeeScript</a>).</p>
<p>To install, first make sure you have a working copy of the latest stable version of <a href="https://nodejs.org/">Node.js</a>. You can then install CoffeeScript globally with <a href="https://www.npmjs.com/">npm</a>:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install --global coffee-script
</code></pre>
</blockquote><p>When you need CoffeeScript as a dependency of a project, within that projects folder you can install it locally:</p>
@ -842,8 +842,7 @@ cubes = (function() {
<span class="bookmark" id="literate"></span>
<h2>Literate CoffeeScript</h2>
<p>Besides being used as an ordinary programming language, CoffeeScript may also be written in “literate” mode. If you name your file with a <code>.litcoffee</code> extension, you can write it as a Markdown document — a document that also happens to be executable CoffeeScript code. The compiler will treat any indented blocks (Markdowns way of indicating source code) as code, and ignore the rest as comments.</p>
<p>Just for kicks, a little bit of the compiler is currently implemented in this fashion: See it <a href="https://gist.github.com/jashkenas/3fc3c1a8b1009c00d9df">as a document</a>, <a href="https://raw.github.com/jashkenas/coffeescript/master/src/scope.litcoffee">raw</a>, and <a href="http://cl.ly/LxEu">properly highlighted in a text editor</a>.</p>
<p>Im fairly excited about this direction for the language, and am looking forward to writing (and more importantly, reading) more programs in this style. More information about Literate CoffeeScript, including an <a href="https://github.com/jashkenas/journo">example program</a>, are <a href="http://ashkenas.com/literate-coffeescript">available in this blog post</a>.</p>
<p>Just for kicks, a little bit of the compiler is currently implemented in this fashion: See it <a href="https://gist.github.com/jashkenas/3fc3c1a8b1009c00d9df">as a document</a>, <a href="https://raw.githubusercontent.com/jashkenas/coffeescript/master/src/scope.litcoffee">raw</a>, and <a href="http://cl.ly/LxEu">properly highlighted in a text editor</a>.</p>
<span class="bookmark" id="language"></span>
<h2>Language Reference</h2>
@ -1470,7 +1469,7 @@ alert((function() {
<p><code>unless</code> can be used as the inverse of <code>if</code>.</p>
<p>As a shortcut for <code>this.property</code>, you can use <code>@property</code>.</p>
<p>You can use <code>in</code> to test for array presence, and <code>of</code> to test for JavaScript object-key presence.</p>
<p>To simplify math expressions, <code>**</code> can be used for exponentiation and <code>//</code> performs integer division. <code>%</code> works just like in JavaScript, while <code>%%</code> provides <a href="http://en.wikipedia.org/wiki/Modulo_operation">“dividend dependent modulo”</a>:</p>
<p>To simplify math expressions, <code>**</code> can be used for exponentiation and <code>//</code> performs integer division. <code>%</code> works just like in JavaScript, while <code>%%</code> provides <a href="https://en.wikipedia.org/wiki/Modulo_operation">“dividend dependent modulo”</a>:</p>
<div class='code'><pre><code><span class="number">-7</span> % <span class="number">5</span> == <span class="number">-2</span> <span class="comment"># The remainder of 7 / 5</span>
<span class="number">-7</span> %% <span class="number">5</span> == <span class="number">3</span> <span class="comment"># n %% 5 is always between 0 and 4</span>
@ -1625,7 +1624,7 @@ zip = <span class="keyword">typeof</span> lottery.drawWinner === <span class="st
<span class="bookmark" id="classes"></span>
<h2>Classes, Inheritance, and Super</h2>
<p>JavaScripts prototypal inheritance has always been a bit of a brain-bender, with a whole family tree of libraries that provide a cleaner syntax for classical inheritance on top of JavaScripts prototypes: <a href="http://code.google.com/p/base2/">Base2</a>, <a href="http://prototypejs.org/">Prototype.js</a>, <a href="http://jsclass.jcoglan.com/">JS.Class</a>, etc. The libraries provide syntactic sugar, but the built-in inheritance would be completely usable if it werent for a couple of small exceptions: its awkward to call <strong>super</strong> (the prototype objects implementation of the current function), and its awkward to correctly set the prototype chain.</p>
<p>JavaScripts prototypal inheritance has always been a bit of a brain-bender, with a whole family tree of libraries that provide a cleaner syntax for classical inheritance on top of JavaScripts prototypes: <a href="https://code.google.com/p/base2/">Base2</a>, <a href="http://prototypejs.org/">Prototype.js</a>, <a href="http://jsclass.jcoglan.com/">JS.Class</a>, etc. The libraries provide syntactic sugar, but the built-in inheritance would be completely usable if it werent for a couple of small exceptions: its awkward to call <strong>super</strong> (the prototype objects implementation of the current function), and its awkward to correctly set the prototype chain.</p>
<p>Instead of repetitively attaching functions to a prototype, CoffeeScript provides a basic <code>class</code> structure that allows you to name your class, set the superclass, assign prototypal properties, and define the constructor, in a single assignable expression.</p>
<p>Constructor functions are named, to better support helpful stack traces. In the first class in the example below, <code>this.constructor.name is &quot;Animal&quot;</code>.</p>
<div class='code'><pre><code><span class="class"><span class="keyword">class</span> <span class="title">Animal</span></span>
@ -1950,6 +1949,7 @@ Account = <span class="function"><span class="keyword">function</span>(<span cla
};
</code></pre><script>window.example1 = "Account = (customer, cart) ->\n @customer = customer\n @cart = cart\n\n $('.shopping_cart').on 'click', (event) =>\n @customer.purchase @cart\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example1);'>load</div><br class='clear' /></div><p>If we had used <code>-&gt;</code> in the callback above, <code>@customer</code> would have referred to the undefined “customer” property of the DOM element, and trying to call <code>purchase()</code> on it would have raised an exception.</p>
<p>When used in a class definition, methods declared with the fat arrow will be automatically bound to each instance of the class when the instance is constructed.</p>
<div id="generator-functions" class="bookmark"></div>
<p>CoffeeScript functions also support <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">ES2015 generator functions</a> through the <code>yield</code> keyword. Theres no <code>function*(){}</code> nonsense — a generator in CoffeeScript is simply a function that yields.</p>
<div class='code'><pre><code><span class="function"><span class="title">perfectSquares</span> = -&gt;</span>
num = <span class="number">0</span>
@ -1984,6 +1984,7 @@ perfectSquares = function*() {
window.ps || (window.ps = perfectSquares());
;alert(ps.next().value);">run: ps.next().value</div><br class='clear' /></div><p><code>yield*</code> is called <code>yield from</code>, and <code>yield return</code> may be used if you need to force a generator that doesnt yield.</p>
<div id="generator-iteration" class="bookmark"></div>
<p>You can iterate over a generator function using <code>for…from</code>.</p>
<div class='code'><pre><code><span class="function"><span class="title">fibonacci</span> = -&gt;</span>
[previous, current] = [<span class="number">1</span>, <span class="number">1</span>]
@ -2184,7 +2185,7 @@ grade = (<span class="function"><span class="keyword">function</span>(<span clas
</code></pre><script>window.example1 = "try\n allHellBreaksLoose()\n catsAndDogsLivingTogether()\ncatch error\n print error\nfinally\n cleanUp()\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example1);'>load</div><br class='clear' /></div>
<span class="bookmark" id="comparisons"></span>
<h2>Chained Comparisons</h2>
<p>CoffeeScript borrows <a href="http://docs.python.org/reference/expressions.html#notin">chained comparisons</a> from Python — making it easy to test if a value falls within a certain range.</p>
<p>CoffeeScript borrows <a href="https://docs.python.org/3/reference/expressions.html#not-in">chained comparisons</a> from Python — making it easy to test if a value falls within a certain range.</p>
<div class='code'><pre><code>cholesterol = <span class="number">127</span>
healthy = <span class="number">200</span> &gt; cholesterol &gt; <span class="number">60</span>
@ -2405,7 +2406,8 @@ OPERATOR = <span class="regexp">/^(?:[-=]&gt;|[-+*\/%&lt;&gt;&amp;|^!?=]=|&gt;&g
max,
min
} <span class="keyword">from</span> <span class="string">'underscore'</span>;
</code></pre><script>window.example1 = "import 'local-file.coffee'\nimport 'coffee-script'\n\nimport _ from 'underscore'\nimport * as underscore from 'underscore'\n\nimport { now } from 'underscore'\nimport { now as currentTimestamp } from 'underscore'\nimport { first, last } from 'underscore'\nimport utilityBelt, { each } from 'underscore'\n\nexport default Math\nexport square = (x) -> x * x\nexport class Mathematics\n least: (x, y) -> if x < y then x else y\n\nexport { sqrt }\nexport { sqrt as squareRoot }\nexport { Mathematics as default, sqrt as squareRoot }\n\nexport * from 'underscore'\nexport { max, min } from 'underscore'\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example1);'>load</div><br class='clear' /></div><p>Note that the CoffeeScript compiler <strong>does not resolve modules</strong>; writing an <code>import</code> or <code>export</code> statement in CoffeeScript will produce an <code>import</code> or <code>export</code> statement in the resulting output. It is your responsibility attach another transpiler, such as <a href="https://github.com/google/traceur-compiler">Traceur Compiler</a>, <a href="http://babeljs.io/">Babel</a> or <a href="https://github.com/rollup/rollup">Rollup</a>, to convert this ES2015 syntax into code that will work in your target runtimes.</p>
</code></pre><script>window.example1 = "import 'local-file.coffee'\nimport 'coffee-script'\n\nimport _ from 'underscore'\nimport * as underscore from 'underscore'\n\nimport { now } from 'underscore'\nimport { now as currentTimestamp } from 'underscore'\nimport { first, last } from 'underscore'\nimport utilityBelt, { each } from 'underscore'\n\nexport default Math\nexport square = (x) -> x * x\nexport class Mathematics\n least: (x, y) -> if x < y then x else y\n\nexport { sqrt }\nexport { sqrt as squareRoot }\nexport { Mathematics as default, sqrt as squareRoot }\n\nexport * from 'underscore'\nexport { max, min } from 'underscore'\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example1);'>load</div><br class='clear' /></div><div id="modules-note" class="bookmark"></div>
<p>Note that the CoffeeScript compiler <strong>does not resolve modules</strong>; writing an <code>import</code> or <code>export</code> statement in CoffeeScript will produce an <code>import</code> or <code>export</code> statement in the resulting output. It is your responsibility attach another transpiler, such as <a href="https://github.com/google/traceur-compiler">Traceur Compiler</a>, <a href="http://babeljs.io/">Babel</a> or <a href="https://github.com/rollup/rollup">Rollup</a>, to convert this ES2015 syntax into code that will work in your target runtimes.</p>
<p>Also note that any file with an <code>import</code> or <code>export</code> statement will be output without a <a href="#lexical-scope">top-level function safety wrapper</a>; in other words, importing or exporting modules will automatically trigger <a href="#usage">bare</a> mode for that file. This is because per the ES2015 spec, <code>import</code> or <code>export</code> statements must occur at the topmost scope.</p>
<span class="bookmark" id="cake"></span>
@ -2434,16 +2436,16 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
dir = options.output || <span class="string">'lib'</span>;
<span class="keyword">return</span> fs.writeFile(dir + <span class="string">"/parser.js"</span>, code);
});
</code></pre><script>window.example1 = "fs = require 'fs'\n\noption '-o', '--output [DIR]', 'directory for compiled code'\n\ntask 'build:parser', 'rebuild the Jison parser', (options) ->\n require 'jison'\n code = require('./lib/grammar').parser.generate()\n dir = options.output or 'lib'\n fs.writeFile \"#{dir}/parser.js\", code\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example1);'>load</div><br class='clear' /></div><p>If you need to invoke one task before another — for example, running <code>build</code> before <code>test</code>, you can use the <code>invoke</code> function: <code>invoke 'build'</code>. Cake tasks are a minimal way to expose your CoffeeScript functions to the command line, so <a href="v1/annotated-source/cake.html">dont expect any fanciness built-in</a>. If you need dependencies, or async callbacks, its best to put them in your code itself — not the cake task.</p>
</code></pre><script>window.example1 = "fs = require 'fs'\n\noption '-o', '--output [DIR]', 'directory for compiled code'\n\ntask 'build:parser', 'rebuild the Jison parser', (options) ->\n require 'jison'\n code = require('./lib/grammar').parser.generate()\n dir = options.output or 'lib'\n fs.writeFile \"#{dir}/parser.js\", code\n"</script><div class='minibutton load' onclick='javascript: loadConsole(example1);'>load</div><br class='clear' /></div><p>If you need to invoke one task before another — for example, running <code>build</code> before <code>test</code>, you can use the <code>invoke</code> function: <code>invoke 'build'</code>. Cake tasks are a minimal way to expose your CoffeeScript functions to the command line, so <a href="/v1/annotated-source/cake.html">dont expect any fanciness built-in</a>. If you need dependencies, or async callbacks, its best to put them in your code itself — not the cake task.</p>
<span class="bookmark" id="source-maps"></span>
<h2>Source Maps</h2>
<p>CoffeeScript 1.6.1 and above include support for generating source maps, a way to tell your JavaScript engine what part of your CoffeeScript program matches up with the code being evaluated. Browsers that support it can automatically use source maps to show your original source code in the debugger. To generate source maps alongside your JavaScript files, pass the <code>--map</code> or <code>-m</code> flag to the compiler.</p>
<p>For a full introduction to source maps, how they work, and how to hook them up in your browser, read the <a href="http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/">HTML5 Tutorial</a>.</p>
<p>For a full introduction to source maps, how they work, and how to hook them up in your browser, read the <a href="https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/">HTML5 Tutorial</a>.</p>
<span class="bookmark" id="scripts"></span>
<h2>“text/coffeescript” Script Tags</h2>
<p>While its not recommended for serious use, CoffeeScripts may be included directly within the browser using <code>&lt;script type=&quot;text/coffeescript&quot;&gt;</code> tags. The source includes a compressed and minified version of the compiler (<a href="v1/browser-compiler/coffee-script.js">Download current version here, 51k when gzipped</a>) as <code>v1/browser-compiler/coffee-script.js</code>. Include this file on a page with inline CoffeeScript tags, and it will compile and evaluate them in order.</p>
<p>While its not recommended for serious use, CoffeeScripts may be included directly within the browser using <code>&lt;script type=&quot;text/coffeescript&quot;&gt;</code> tags. The source includes a compressed and minified version of the compiler (<a href="/v1/browser-compiler/coffee-script.js">Download current version here, 51k when gzipped</a>) as <code>v1/browser-compiler/coffee-script.js</code>. Include this file on a page with inline CoffeeScript tags, and it will compile and evaluate them in order.</p>
<p>In fact, the little bit of glue script that runs “Try CoffeeScript” above, as well as the jQuery for the menu, is implemented in just this way. View source and look at the bottom of the page to see the example. Including the script also gives you access to <code>CoffeeScript.compile()</code> so you can pop open Firebug and try compiling some strings.</p>
<p>The usual caveats about CoffeeScript apply — your inline scripts will run within a closure wrapper, so if you want to expose global variables or functions, attach them to the <code>window</code> object.</p>
@ -2451,22 +2453,22 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
<h2>Books</h2>
<p>There are a number of excellent resources to help you get started with CoffeeScript, some of which are freely available online.</p>
<ul>
<li><a href="http://arcturo.github.com/library/coffeescript/">The Little Book on CoffeeScript</a> is a brief 5-chapter introduction to CoffeeScript, written with great clarity and precision by <a href="http://alexmaccaw.co.uk/">Alex MacCaw</a>.</li>
<li><a href="http://autotelicum.github.com/Smooth-CoffeeScript/">Smooth CoffeeScript</a> is a reimagination of the excellent book <a href="http://eloquentjavascript.net/">Eloquent JavaScript</a>, as if it had been written in CoffeeScript instead. Covers language features as well as the functional and object oriented programming styles. By <a href="https://github.com/autotelicum">E. Hoigaard</a>.</li>
<li><a href="http://arcturo.github.io/library/coffeescript/">The Little Book on CoffeeScript</a> is a brief 5-chapter introduction to CoffeeScript, written with great clarity and precision by <a href="http://alexmaccaw.co.uk/">Alex MacCaw</a>.</li>
<li><a href="http://autotelicum.github.io/Smooth-CoffeeScript/">Smooth CoffeeScript</a> is a reimagination of the excellent book <a href="http://eloquentjavascript.net/">Eloquent JavaScript</a>, as if it had been written in CoffeeScript instead. Covers language features as well as the functional and object oriented programming styles. By <a href="https://github.com/autotelicum">E. Hoigaard</a>.</li>
<li><a href="http://pragprog.com/book/tbcoffee/coffeescript">CoffeeScript: Accelerated JavaScript Development</a> is <a href="http://trevorburnham.com/">Trevor Burnham</a>s thorough introduction to the language. By the end of the book, youll have built a fast-paced multiplayer word game, writing both the client-side and Node.js portions in CoffeeScript.</li>
<li><a href="http://www.packtpub.com/coffeescript-programming-with-jquery-rails-nodejs/book">CoffeeScript Programming with jQuery, Rails, and Node.js</a> is a new book by Michael Erasmus that covers CoffeeScript with an eye towards real-world usage both in the browser (jQuery) and on the server-side (Rails, Node).</li>
<li><a href="https://www.packtpub.com/web-development/coffeescript-programming-jquery-rails-and-nodejs">CoffeeScript Programming with jQuery, Rails, and Node.js</a> is a new book by Michael Erasmus that covers CoffeeScript with an eye towards real-world usage both in the browser (jQuery) and on the server-side (Rails, Node).</li>
<li><a href="https://leanpub.com/coffeescript-ristretto/read">CoffeeScript Ristretto</a> is a deep dive into CoffeeScripts semantics from simple functions up through closures, higher-order functions, objects, classes, combinators, and decorators. By <a href="http://braythwayt.com/">Reg Braithwaite</a>.</li>
<li><a href="https://efendibooks.com/minibooks/testing-with-coffeescript">Testing with CoffeeScript</a> is a succinct and freely downloadable guide to building testable applications with CoffeeScript and Jasmine.</li>
<li><a href="http://www.packtpub.com/coffeescript-application-development/book">CoffeeScript Application Development</a> from Packt, introduces CoffeeScript while walking through the process of building a demonstration web application. A <a href="https://www.packtpub.com/web-development/coffeescript-application-development-cookbook">CoffeeScript Application Development Coookbook</a> with over 90 “recipes” is also available.</li>
<li><a href="http://www.manning.com/lee/">CoffeeScript in Action</a> from Manning Publications, covers CoffeeScript syntax, composition techniques and application development.</li>
<li><a href="http://www.dpunkt.de/buecher/4021/coffeescript.html">CoffeeScript: Die Alternative zu JavaScript</a> from dpunkt.verlag, is the first CoffeeScript book in Deutsch.</li>
<li><a href="https://www.packtpub.com/web-development/coffeescript-application-development">CoffeeScript Application Development</a> from Packt, introduces CoffeeScript while walking through the process of building a demonstration web application. A <a href="https://www.packtpub.com/web-development/coffeescript-application-development-cookbook">CoffeeScript Application Development Coookbook</a> with over 90 “recipes” is also available.</li>
<li><a href="https://www.manning.com/books/coffeescript-in-action">CoffeeScript in Action</a> from Manning Publications, covers CoffeeScript syntax, composition techniques and application development.</li>
<li><a href="https://www.dpunkt.de/buecher/4021/coffeescript.html">CoffeeScript: Die Alternative zu JavaScript</a> from dpunkt.verlag, is the first CoffeeScript book in Deutsch.</li>
</ul>
<span class="bookmark" id="screencasts"></span>
<h2>Screencasts</h2>
<ul>
<li><a href="http://coffeescript.codeschool.com">A Sip of CoffeeScript</a> is a <a href="http://www.codeschool.com">Code School Course</a> which combines 6 screencasts with in-browser coding to make learning fun. The first level is free to try out.</li>
<li><a href="http://peepcode.com/products/coffeescript">Meet CoffeeScript</a> is a 75-minute long screencast by <a href="http://peepcode.com/">PeepCode</a>. Highly memorable for its animations which demonstrate transforming CoffeeScript into the equivalent JS.</li>
<li><a href="http://coffeescript.codeschool.com/">A Sip of CoffeeScript</a> is a <a href="https://www.codeschool.com">Code School Course</a> which combines 6 screencasts with in-browser coding to make learning fun. The first level is free to try out.</li>
<li><a href="https://www.pluralsight.com/courses/meet-coffeescript">Meet CoffeeScript</a> is a 75-minute long screencast by PeepCode, now <a href="https://www.pluralsight.com/">PluralSight</a>. Highly memorable for its animations which demonstrate transforming CoffeeScript into the equivalent JS.</li>
<li>If youre looking for less of a time commitment, RailsCasts <a href="http://railscasts.com/episodes/267-coffeescript-basics">CoffeeScript Basics</a> should have you covered, hitting all of the important notes about CoffeeScript in 11 minutes.</li>
</ul>
@ -2474,10 +2476,9 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
<h2>Examples</h2>
<p>The <a href="https://github.com/trending?l=coffeescript&amp;since=monthly">best list of open-source CoffeeScript examples</a> can be found on GitHub. But just to throw out a few more:</p>
<ul>
<li><strong>GitHub</strong>s <a href="http://hubot.github.com/">Hubot</a>, a friendly IRC robot that can perform any number of useful and useless tasks.</li>
<li><strong>GitHub</strong>s <a href="https://hubot.github.com/">Hubot</a>, a friendly IRC robot that can perform any number of useful and useless tasks.</li>
<li><strong>sstephenson</strong>s <a href="http://pow.cx/">Pow</a>, a zero-configuration Rack server, with comprehensive annotated source.</li>
<li><strong>technoweenie</strong>s <a href="https://github.com/technoweenie/coffee-resque">Coffee-Resque</a>, a port of <a href="https://github.com/defunkt/resque">Resque</a> for Node.js.</li>
<li><strong>assaf</strong>s <a href="http://zombie.labnotes.org/">Zombie.js</a>, a headless, full-stack, faux-browser testing library for Node.js.</li>
<li><strong>stephank</strong>s <a href="https://github.com/stephank/orona">Orona</a>, a remake of the Bolo tank game for modern browsers.</li>
<li><strong>GitHub</strong>s <a href="https://atom.io/">Atom</a>, a hackable text editor built on web technologies.</li>
<li><strong>Basecamp</strong>s <a href="https://trix-editor.org/">Trix</a>, a rich text editor for web apps.</li>
@ -2487,7 +2488,7 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
<h2>Resources</h2>
<ul>
<li>
<p><a href="http://github.com/jashkenas/coffeescript/">Source Code</a><br>
<p><a href="https://github.com/jashkenas/coffeescript/">Source Code</a><br>
Use <code>bin/coffee</code> to test your changes,<br>
<code>bin/cake test</code> to run the test suite,<br>
<code>bin/cake build</code> to rebuild the full CoffeeScript compiler, and<br>
@ -2495,11 +2496,11 @@ Use <code>bin/coffee</code> to test your changes,<br>
<p><code>git checkout lib &amp;&amp; bin/cake build:full</code> is a good command to run when youre working on the core language. Itll refresh the <code>lib</code> folder (in case you broke something), build your altered compiler, use that to rebuild itself (a good sanity test) and then run all of the tests. If they pass, theres a good chance youve made a successful change.</p>
</li>
<li>
<p><a href="v1/test.html">Browser Tests</a><br>
<p><a href="/v1/test.html">Browser Tests</a><br>
Run CoffeeScripts test suite in your current browser.</p>
</li>
<li>
<p><a href="http://github.com/jashkenas/coffeescript/issues">CoffeeScript Issues</a><br>
<p><a href="https://github.com/jashkenas/coffeescript/issues">CoffeeScript Issues</a><br>
Bug reports, feature proposals, and ideas for changes to the language belong here.</p>
</li>
<li>
@ -2507,11 +2508,11 @@ Bug reports, feature proposals, and ideas for changes to the language belong her
If youd like to ask a question, the mailing list is a good place to get help.</p>
</li>
<li>
<p><a href="http://github.com/jashkenas/coffeescript/wiki">The CoffeeScript Wiki</a><br>
If youve ever learned a neat CoffeeScript tip or trick, or ran into a gotcha — share it on the wiki. The wiki also serves as a directory of handy <a href="http://github.com/jashkenas/coffeescript/wiki/Text-editor-plugins">text editor extensions</a>, <a href="http://github.com/jashkenas/coffeescript/wiki/Web-framework-plugins">web framework plugins</a>, and general <a href="http://github.com/jashkenas/coffeescript/wiki/Build-tools">CoffeeScript build tools</a>.</p>
<p><a href="https://github.com/jashkenas/coffeescript/wiki">The CoffeeScript Wiki</a><br>
If youve ever learned a neat CoffeeScript tip or trick, or ran into a gotcha — share it on the wiki. The wiki also serves as a directory of handy <a href="https://github.com/jashkenas/coffeescript/wiki/Text-editor-plugins">text editor extensions</a>, <a href="https://github.com/jashkenas/coffeescript/wiki/Web-framework-plugins">web framework plugins</a>, and general <a href="https://github.com/jashkenas/coffeescript/wiki/Build-tools">CoffeeScript build tools</a>.</p>
</li>
<li>
<p><a href="http://github.com/jashkenas/coffeescript/wiki/FAQ">The FAQ</a><br>
<p><a href="https://github.com/jashkenas/coffeescript/wiki/FAQ">The FAQ</a><br>
Perhaps your CoffeeScript-related question has been asked before. Check the FAQ first.</p>
</li>
<li>
@ -2566,7 +2567,7 @@ The CoffeeScript logo is available in SVG for use in presentations.</p>
<li>The browser compiler can once again be built unminified via <code>MINIFY=false cake build:browser</code>.</li>
<li>The error-prone patched version of <code>Error.prepareStackTrace</code> has been removed.</li>
<li>Command completion in the REPL (pressing tab to get suggestions) has been fixed for Node 6.9.1+.</li>
<li>The <a href="v1/test.html">browser-based tests</a> now include all the tests as the Node-based version.</li>
<li>The <a href="/v1/test.html">browser-based tests</a> now include all the tests as the Node-based version.</li>
</ul>
<div class="anchor" id="1.12.1"></div>
<h2 class="header">
@ -2585,7 +2586,7 @@ The CoffeeScript logo is available in SVG for use in presentations.</p>
<li>CoffeeScript now provides a <a href="#generator-iteration"><code>for…from</code></a> syntax for outputting ES2015 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of"><code>for…of</code></a>. (Sorry they couldnt match, but we came up with <code>for…of</code> first for something else.) This allows iterating over generators or any other iterable object. Note that using <code>for…from</code> in your code makes you responsible for ensuring that either your runtime supports <code>for…of</code> or that you transpile the output JavaScript further to a version your target runtime(s) support.</li>
<li>Triple backticks (<code>```</code>) allow the creation of embedded JavaScript blocks where escaping single backticks is not required, which should improve interoperability with ES2015 template literals and with Markdown.</li>
<li>Within single-backtick embedded JavaScript, backticks can now be escaped via <code>\`</code>.</li>
<li>The browser tests now run in the browser again, and are accessible <a href="v1/test.html">here</a> if you would like to test your browser.</li>
<li>The browser tests now run in the browser again, and are accessible <a href="/v1/test.html">here</a> if you would like to test your browser.</li>
<li>CoffeeScript-only keywords in ES2015 <code>import</code>s and <code>export</code>s are now ignored.</li>
<li>The compiler now throws an error on trying to export an anonymous class.</li>
<li>Bugfixes related to tokens and location data, for better source maps and improved compatibility with downstream tools.</li>
@ -2800,7 +2801,7 @@ six = -&gt;
<a href="https://github.com/jashkenas/coffeescript/compare/1.5.0...1.6.1">1.6.1</a>
<span class="timestamp"> &mdash; <time datetime="2013-03-05">March 5, 2013</time></span>
</h2><ul>
<li>First release of <a href="#source-maps">source maps</a>. Pass the <code>--map</code> flag to the compiler, and off you go. Direct all your thanks over to <a href="http://github.com/jwalton">Jason Walton</a>.</li>
<li>First release of <a href="#source-maps">source maps</a>. Pass the <code>--map</code> flag to the compiler, and off you go. Direct all your thanks over to <a href="https://github.com/jwalton">Jason Walton</a>.</li>
<li>Fixed a 1.5.0 regression with multiple implicit calls against an indented implicit object. Combinations of implicit function calls and implicit objects should generally be parsed better now — but it still isnt good <em>style</em> to nest them too heavily.</li>
<li><code>.coffee.md</code> is now also supported as a Literate CoffeeScript file extension, for existing tooling. <code>.litcoffee</code> remains the canonical one.</li>
<li>Several minor fixes surrounding member properties, bound methods and <code>super</code> in class declarations.</li>
@ -2907,7 +2908,7 @@ six = -&gt;
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.4...0.9.5">0.9.5</a>
<span class="timestamp"> &mdash; <time datetime="2010-11-21">November 21, 2010</time></span>
</h2><p>0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from <strong>satyr</strong>s <a href="http://github.com/satyr/coco">Coco</a> dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. <code>undefined</code> now works like <code>null</code>, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: <code>result = i for i in list</code>
</h2><p>0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from <strong>satyr</strong>s <a href="https://github.com/satyr/coco">Coco</a> dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. <code>undefined</code> now works like <code>null</code>, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: <code>result = i for i in list</code>
used to parse as <code>result = (i for i in list)</code> by default … it now parses as
<code>(result = i) for i in list</code>.</p>
<div class="anchor" id="0.9.4"></div>
@ -2974,7 +2975,7 @@ used to parse as <code>result = (i for i in list)</code> by default … it now p
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.4...0.5.5">0.5.5</a>
<span class="timestamp"> &mdash; <time datetime="2010-03-08">March 8, 2010</time></span>
</h2><p>String interpolation, contributed by <a href="http://github.com/StanAngeloff">Stan Angeloff</a>. Since <code>--run</code> has been the default since <strong>0.5.3</strong>, updating <code>--stdio</code> and <code>--eval</code> to run by default, pass <code>--compile</code> as well if youd like to print the result.</p>
</h2><p>String interpolation, contributed by <a href="https://github.com/StanAngeloff">Stan Angeloff</a>. Since <code>--run</code> has been the default since <strong>0.5.3</strong>, updating <code>--stdio</code> and <code>--eval</code> to run by default, pass <code>--compile</code> as well if youd like to print the result.</p>
<div class="anchor" id="0.5.4"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.3...0.5.4">0.5.4</a>
@ -2990,7 +2991,7 @@ used to parse as <code>result = (i for i in list)</code> by default … it now p
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.1...0.5.2">0.5.2</a>
<span class="timestamp"> &mdash; <time datetime="2010-02-25">February 25, 2010</time></span>
</h2><p>Added a compressed version of the compiler for inclusion in web pages as
<code>v1/browser-compiler/coffee-script.js</code>. Itll automatically run any script tags with type <code>text/coffeescript</code> for you. Added a <code>--stdio</code> option to the <code>coffee</code> command, for piped-in compiles.</p>
<code>/v1/browser-compiler/coffee-script.js</code>. Itll automatically run any script tags with type <code>text/coffeescript</code> for you. Added a <code>--stdio</code> option to the <code>coffee</code> command, for piped-in compiles.</p>
<div class="anchor" id="0.5.1"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.0...0.5.1">0.5.1</a>
@ -3056,7 +3057,7 @@ The <code>extends</code> keyword now functions identically to <code>goog.inherit
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.6...0.2.0">0.2.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-05">January 5, 2010</time></span>
</h2><p>Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to <a href="http://github.com/liamoc">Liam OConnor-Davis</a> for whitespace and expression help.</p>
</h2><p>Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to <a href="https://github.com/liamoc">Liam OConnor-Davis</a> for whitespace and expression help.</p>
<div class="anchor" id="0.1.6"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.5...0.1.6">0.1.6</a>
@ -3071,7 +3072,7 @@ The <code>extends</code> keyword now functions identically to <code>goog.inherit
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.3...0.1.4">0.1.4</a>
<span class="timestamp"> &mdash; <time datetime="2009-12-25">December 25, 2009</time></span>
</h2><p>The official CoffeeScript extension is now <code>.coffee</code> instead of <code>.cs</code>, which properly belongs to <a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a>. Due to popular demand, you can now also use <code>=</code> to assign. Unlike JavaScript, <code>=</code> can also be used within object literals, interchangeably with <code>:</code>. Made a grammatical fix for chained function calls like <code>func(1)(2)(3)(4)</code>. Inheritance and super no longer use <code>__proto__</code>, so they should be IE-compatible now.</p>
</h2><p>The official CoffeeScript extension is now <code>.coffee</code> instead of <code>.cs</code>, which properly belongs to <a href="https://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a>. Due to popular demand, you can now also use <code>=</code> to assign. Unlike JavaScript, <code>=</code> can also be used within object literals, interchangeably with <code>:</code>. Made a grammatical fix for chained function calls like <code>func(1)(2)(3)(4)</code>. Inheritance and super no longer use <code>__proto__</code>, so they should be IE-compatible now.</p>
<div class="anchor" id="0.1.3"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.2...0.1.3">0.1.3</a>

View File

@ -116,7 +116,7 @@
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p><code>cake</code> is a simplified version of <a href="http://www.gnu.org/software/make/">Make</a>
(<a href="http://rake.rubyforge.org/">Rake</a>, <a href="http://github.com/280north/jake">Jake</a>)
(<a href="http://rake.rubyforge.org/">Rake</a>, <a href="https://github.com/280north/jake">Jake</a>)
for CoffeeScript. You define tasks with names and descriptions in a Cakefile,
and can call them from the command line, or invoke them from other tasks.</p>
<p>Running <code>cake</code> with no arguments will print out a list of all the tasks in the

View File

@ -115,17 +115,17 @@
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
<p>The CoffeeScript parser is generated by <a href="http://github.com/zaach/jison">Jison</a>
<p>The CoffeeScript parser is generated by <a href="https://github.com/zaach/jison">Jison</a>
from this grammar file. Jison is a bottom-up parser generator, similar in
style to <a href="http://www.gnu.org/software/bison">Bison</a>, implemented in JavaScript.
It can recognize <a href="http://en.wikipedia.org/wiki/LR_grammar">LALR(1), LR(0), SLR(1), and LR(1)</a>
It can recognize <a href="https://en.wikipedia.org/wiki/LR_grammar">LALR(1), LR(0), SLR(1), and LR(1)</a>
type grammars. To create the Jison parser, we list the pattern to match
on the left-hand side, and the action to take (usually the creation of syntax
tree nodes) on the right. As the parser runs, it
shifts tokens from our token stream, from left to right, and
<a href="http://en.wikipedia.org/wiki/Bottom-up_parsing">attempts to match</a>
<a href="https://en.wikipedia.org/wiki/Bottom-up_parsing">attempts to match</a>
the token sequence against the rules below. When a match can be made, it
reduces into the <a href="http://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols">nonterminal</a>
reduces into the <a href="https://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols">nonterminal</a>
(the enclosing name at the top), and we proceed from there.</p>
<p>If you run the <code>cake build:parser</code> command, Jison constructs a parse table
from our rules and saves it into <code>lib/parser.js</code>.</p>
@ -199,7 +199,7 @@ wrapper and just returning the value directly.</p>
<a class="pilcrow" href="#section-6">&#182;</a>
</div>
<p>Our handy DSL for Jison grammar generation, thanks to
<a href="http://github.com/creationix">Tim Caswell</a>. For every rule in the grammar,
<a href="https://github.com/creationix">Tim Caswell</a>. For every rule in the grammar,
we pass the pattern-defining string, the action to run, and extra options,
optionally. If no action is specified, we simply pass the value of the
previous nonterminal.</p>

View File

@ -121,7 +121,7 @@ a token is produced, we consume the match, and start again. Tokens are in the
form:</p>
<pre><code>[tag, value, locationData]
</code></pre><p>where locationData is {first_line, first_column, last_line, last_column}, which is a
format that can be fed directly into <a href="http://github.com/zaach/jison">Jison</a>. These
format that can be fed directly into <a href="https://github.com/zaach/jison">Jison</a>. These
are read by jison in the <code>parser.lexer</code> function defined in coffeescript.coffee.</p>
</div>

View File

@ -4985,7 +4985,7 @@ CoffeeScript operations into their JavaScript equivalents.</p>
<a class="pilcrow" href="#section-197">&#182;</a>
</div>
<p>Am I capable of
<a href="http://docs.python.org/reference/expressions.html#notin">Python-style comparison chaining</a>?</p>
<a href="https://docs.python.org/3/reference/expressions.html#not-in">Python-style comparison chaining</a>?</p>
</div>

View File

@ -406,7 +406,7 @@ column for the current line:</p>
</div>
<p>Note that SourceMap VLQ encoding is “backwards”. MIDI-style VLQ encoding puts
the most-significant-bit (MSB) from the original value into the MSB of the VLQ
encoded value (see <a href="http://en.wikipedia.org/wiki/File:Uintvar_coding.svg">Wikipedia</a>).
encoded value (see <a href="https://en.wikipedia.org/wiki/File:Uintvar_coding.svg">Wikipedia</a>).
SourceMap VLQ does things the other way around, with the least significat four
bits of the original value encoded into the first byte of the VLQ encoded value.</p>

View File

@ -714,7 +714,7 @@ textarea {
<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>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="http://github.com/jashkenas/coffeescript/tarball/2.0.0-beta1">2.0.0-beta1</a></p>
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.0.0-beta1">2.0.0-beta1</a></p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install -g coffeescript@next
</code></pre>
</blockquote>
@ -825,8 +825,8 @@ coffee -p *.coffee | babel --presets env &gt; app.js
</section>
<section id="installation">
<h2>Installation</h2>
<p>The command-line version of <code>coffee</code> is available as a <a href="http://nodejs.org/">Node.js</a> utility. The <a href="/v2/browser-compiler/coffeescript.js">core compiler</a> however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see <a href="#try">Try CoffeeScript</a>).</p>
<p>To install, first make sure you have a working copy of the latest stable version of <a href="http://nodejs.org/">Node.js</a>. You can then install CoffeeScript globally with <a href="http://npmjs.org">npm</a>:</p>
<p>The command-line version of <code>coffee</code> is available as a <a href="https://nodejs.org/">Node.js</a> utility. The <a href="/v2/browser-compiler/coffeescript.js">core compiler</a> however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see <a href="#try">Try CoffeeScript</a>).</p>
<p>To install, first make sure you have a working copy of the latest stable version of <a href="https://nodejs.org/">Node.js</a>. You can then install CoffeeScript globally with <a href="https://www.npmjs.com/">npm</a>:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install --global coffeescript@next
</code></pre>
</blockquote><p>When you need CoffeeScript as a dependency of a project, within that projects folder you can install it locally:</p>
@ -1798,7 +1798,7 @@ alert((function() {
<p><code>unless</code> can be used as the inverse of <code>if</code>.</p>
<p>As a shortcut for <code>this.property</code>, you can use <code>@property</code>.</p>
<p>You can use <code>in</code> to test for array presence, and <code>of</code> to test for JavaScript object-key presence.</p>
<p>To simplify math expressions, <code>**</code> can be used for exponentiation and <code>//</code> performs integer division. <code>%</code> works just like in JavaScript, while <code>%%</code> provides <a href="http://en.wikipedia.org/wiki/Modulo_operation">“dividend dependent modulo”</a>:</p>
<p>To simplify math expressions, <code>**</code> can be used for exponentiation and <code>//</code> performs integer division. <code>%</code> works just like in JavaScript, while <code>%%</code> provides <a href="https://en.wikipedia.org/wiki/Modulo_operation">“dividend dependent modulo”</a>:</p>
<aside class="code-example container-fluid bg-ribbed-dark" data-example="modulo">
<div class="row">
<div class="col-md-6 coffeescript-input-column">
@ -2379,6 +2379,8 @@ Account = function(customer, cart) {
</aside>
<p>If we had used <code>-&gt;</code> in the callback above, <code>@customer</code> would have referred to the undefined “customer” property of the DOM element, and trying to call <code>purchase()</code> on it would have raised an exception.</p>
<p>When used in a class definition, methods declared with the fat arrow will be automatically bound to each instance of the class when the instance is constructed.</p>
<div id="generator-functions" class="bookmark"></div>
<div id="async-functions" class="bookmark"></div>
<p>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. Theres no <code>function*(){}</code> or <code>async function(){}</code> nonsense — a generator in CoffeeScript is simply a function that yields, and an async function in CoffeeScript is simply a function that awaits.</p>
<aside class="code-example container-fluid bg-ribbed-dark" data-example="generators">
<div class="row">
@ -2418,6 +2420,7 @@ window.ps || (window.ps = perfectSquares());
</aside>
<p><code>yield*</code> is called <code>yield from</code>, and <code>yield return</code> may be used if you need to force a generator that doesnt yield.</p>
<div id="generator-iteration" class="bookmark"></div>
<p>You can iterate over a generator function using <code>for…from</code>.</p>
<aside class="code-example container-fluid bg-ribbed-dark" data-example="generator_iteration">
<div class="row">
@ -2657,7 +2660,7 @@ try {
</section>
<section id="comparisons">
<h2>Chained Comparisons</h2>
<p>CoffeeScript borrows <a href="http://docs.python.org/reference/expressions.html#notin">chained comparisons</a> from Python — making it easy to test if a value falls within a certain range.</p>
<p>CoffeeScript borrows <a href="https://docs.python.org/3/reference/expressions.html#not-in">chained comparisons</a> from Python — making it easy to test if a value falls within a certain range.</p>
<aside class="code-example container-fluid bg-ribbed-dark" data-example="comparisons">
<div class="row">
<div class="col-md-6 coffeescript-input-column">
@ -2851,6 +2854,7 @@ export {
</div>
</aside>
<div id="modules-note" class="bookmark"></div>
<p>Note that the CoffeeScript compiler <strong>does not resolve modules</strong>; writing an <code>import</code> or <code>export</code> statement in CoffeeScript will produce an <code>import</code> or <code>export</code> statement in the resulting output. It is your responsibility attach another transpiler, such as <a href="https://github.com/google/traceur-compiler">Traceur Compiler</a>, <a href="http://babeljs.io/">Babel</a> or <a href="https://github.com/rollup/rollup">Rollup</a>, to convert this ES2015 syntax into code that will work in your target runtimes.</p>
<p>Also note that any file with an <code>import</code> or <code>export</code> statement will be output without a <a href="#lexical-scope">top-level function safety wrapper</a>; in other words, importing or exporting modules will automatically trigger <a href="#usage">bare</a> mode for that file. This is because per the ES2015 spec, <code>import</code> or <code>export</code> statements must occur at the topmost scope.</p>
@ -3006,13 +3010,13 @@ Object.defineProperty(screen, 'height', {
<section id="literate">
<h2>Literate CoffeeScript</h2>
<p>Besides being used as an ordinary programming language, CoffeeScript may also be written in “literate” mode. If you name your file with a <code>.litcoffee</code> extension, you can write it as a Markdown document — a document that also happens to be executable CoffeeScript code. The compiler will treat any indented blocks (Markdowns way of indicating source code) as code, and ignore the rest as comments.</p>
<p>Just for kicks, a little bit of the compiler is currently implemented in this fashion: See it <a href="https://gist.github.com/jashkenas/3fc3c1a8b1009c00d9df">as a document</a>, <a href="https://raw.github.com/jashkenas/coffeescript/master/src/scope.litcoffee">raw</a>, and <a href="http://cl.ly/LxEu">properly highlighted in a text editor</a>.</p>
<p>Just for kicks, a little bit of the compiler is currently implemented in this fashion: See it <a href="https://gist.github.com/jashkenas/3fc3c1a8b1009c00d9df">as a document</a>, <a href="https://raw.githubusercontent.com/jashkenas/coffeescript/master/src/scope.litcoffee">raw</a>, and <a href="http://cl.ly/LxEu">properly highlighted in a text editor</a>.</p>
</section>
<section id="source-maps">
<h2>Source Maps</h2>
<p>CoffeeScript includes support for generating source maps, a way to tell your JavaScript engine what part of your CoffeeScript program matches up with the code being evaluated. Browsers that support it can automatically use source maps to show your original source code in the debugger. To generate source maps alongside your JavaScript files, pass the <code>--map</code> or <code>-m</code> flag to the compiler.</p>
<p>For a full introduction to source maps, how they work, and how to hook them up in your browser, read the <a href="http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/">HTML5 Tutorial</a>.</p>
<p>For a full introduction to source maps, how they work, and how to hook them up in your browser, read the <a href="https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/">HTML5 Tutorial</a>.</p>
</section>
<section id="cake">
@ -3057,7 +3061,7 @@ task('build:parser', 'rebuild the Jison parser', function(options) {
</section>
<section id="scripts">
<h2><code>&quot;text/coffeescript&quot;</code> Script Tags</h2>
<p>While its not recommended for serious use, CoffeeScripts may be included directly within the browser using <code>&lt;script type=&quot;text/coffeescript&quot;&gt;</code> tags. The source includes a compressed and minified version of the compiler (<a href="/v2/browser-compiler/coffeescript.js">Download current version here, 51k when gzipped</a>) as <code>v2/browser-compiler/coffeescript.js</code>. Include this file on a page with inline CoffeeScript tags, and it will compile and evaluate them in order.</p>
<p>While its not recommended for serious use, CoffeeScripts may be included directly within the browser using <code>&lt;script type=&quot;text/coffeescript&quot;&gt;</code> tags. The source includes a compressed and minified version of the compiler (<a href="/v2/browser-compiler/coffeescript.js">Download current version here, 51k when gzipped</a>) as <code>docs/v2/browser-compiler/coffeescript.js</code>. Include this file on a page with inline CoffeeScript tags, and it will compile and evaluate them in order.</p>
<p>In fact, the little bit of glue script that runs <a href="#try">Try CoffeeScript</a>, as well as the code examples and other interactive parts of this site, is implemented in just this way. View source and look at the bottom of the page to see the example. Including the script also gives you access to <code>CoffeeScript.compile()</code> so you can pop open your JavaScript console and try compiling some strings.</p>
<p>The usual caveats about CoffeeScript apply — your inline scripts will run within a closure wrapper, so if you want to expose global variables or functions, attach them to the <code>window</code> object.</p>
@ -3065,14 +3069,14 @@ task('build:parser', 'rebuild the Jison parser', function(options) {
<section id="resources">
<h2>Resources</h2>
<ul>
<li><a href="http://github.com/jashkenas/coffeescript/">CoffeeScript on GitHub</a></li>
<li><a href="http://github.com/jashkenas/coffeescript/issues">CoffeeScript Issues</a><br>
<li><a href="https://github.com/jashkenas/coffeescript/">CoffeeScript on GitHub</a></li>
<li><a href="https://github.com/jashkenas/coffeescript/issues">CoffeeScript Issues</a><br>
Bug reports, feature proposals, and ideas for changes to the language belong here.</li>
<li><a href="https://groups.google.com/forum/#!forum/coffeescript">CoffeeScript Google Group</a><br>
If youd like to ask a question, the mailing list is a good place to get help.</li>
<li><a href="http://github.com/jashkenas/coffeescript/wiki">The CoffeeScript Wiki</a><br>
If youve ever learned a neat CoffeeScript tip or trick, or ran into a gotcha — share it on the wiki. The wiki also serves as a directory of handy <a href="http://github.com/jashkenas/coffeescript/wiki/Text-editor-plugins">text editor extensions</a>, <a href="http://github.com/jashkenas/coffeescript/wiki/Web-framework-plugins">web framework plugins</a>, and general <a href="http://github.com/jashkenas/coffeescript/wiki/Build-tools">CoffeeScript build tools</a>.</li>
<li><a href="http://github.com/jashkenas/coffeescript/wiki/FAQ">The FAQ</a><br>
<li><a href="https://github.com/jashkenas/coffeescript/wiki">The CoffeeScript Wiki</a><br>
If youve ever learned a neat CoffeeScript tip or trick, or ran into a gotcha — share it on the wiki. The wiki also serves as a directory of handy <a href="https://github.com/jashkenas/coffeescript/wiki/Text-editor-plugins">text editor extensions</a>, <a href="https://github.com/jashkenas/coffeescript/wiki/Web-framework-plugins">web framework plugins</a>, and general <a href="https://github.com/jashkenas/coffeescript/wiki/Build-tools">CoffeeScript build tools</a>.</li>
<li><a href="https://github.com/jashkenas/coffeescript/wiki/FAQ">The FAQ</a><br>
Perhaps your CoffeeScript-related question has been asked before. Check the FAQ first.</li>
<li><a href="http://js2.coffee/">JS2Coffee</a><br>
Is a very well done reverse JavaScript-to-CoffeeScript compiler. Its not going to be perfect (infer what your JavaScript classes are, when you need bound functions, and so on…) — but its a great starting point for converting simple scripts.</li>
@ -3084,23 +3088,23 @@ The CoffeeScript logo is available in SVG for use in presentations.</li>
<h2>Books</h2>
<p>There are a number of excellent resources to help you get started with CoffeeScript, some of which are freely available online.</p>
<ul>
<li><a href="http://arcturo.github.com/library/coffeescript/">The Little Book on CoffeeScript</a> is a brief 5-chapter introduction to CoffeeScript, written with great clarity and precision by <a href="http://alexmaccaw.co.uk/">Alex MacCaw</a>.</li>
<li><a href="http://autotelicum.github.com/Smooth-CoffeeScript/">Smooth CoffeeScript</a> is a reimagination of the excellent book <a href="http://eloquentjavascript.net/">Eloquent JavaScript</a>, as if it had been written in CoffeeScript instead. Covers language features as well as the functional and object oriented programming styles. By <a href="https://github.com/autotelicum">E. Hoigaard</a>.</li>
<li><a href="http://arcturo.github.io/library/coffeescript/">The Little Book on CoffeeScript</a> is a brief 5-chapter introduction to CoffeeScript, written with great clarity and precision by <a href="http://alexmaccaw.co.uk/">Alex MacCaw</a>.</li>
<li><a href="http://autotelicum.github.io/Smooth-CoffeeScript/">Smooth CoffeeScript</a> is a reimagination of the excellent book <a href="http://eloquentjavascript.net/">Eloquent JavaScript</a>, as if it had been written in CoffeeScript instead. Covers language features as well as the functional and object oriented programming styles. By <a href="https://github.com/autotelicum">E. Hoigaard</a>.</li>
<li><a href="http://pragprog.com/book/tbcoffee/coffeescript">CoffeeScript: Accelerated JavaScript Development</a> is <a href="http://trevorburnham.com/">Trevor Burnham</a>s thorough introduction to the language. By the end of the book, youll have built a fast-paced multiplayer word game, writing both the client-side and Node.js portions in CoffeeScript.</li>
<li><a href="http://www.packtpub.com/coffeescript-programming-with-jquery-rails-nodejs/book">CoffeeScript Programming with jQuery, Rails, and Node.js</a> is a new book by Michael Erasmus that covers CoffeeScript with an eye towards real-world usage both in the browser (jQuery) and on the server-side (Rails, Node).</li>
<li><a href="https://www.packtpub.com/web-development/coffeescript-programming-jquery-rails-and-nodejs">CoffeeScript Programming with jQuery, Rails, and Node.js</a> is a new book by Michael Erasmus that covers CoffeeScript with an eye towards real-world usage both in the browser (jQuery) and on the server-side (Rails, Node).</li>
<li><a href="https://leanpub.com/coffeescript-ristretto/read">CoffeeScript Ristretto</a> is a deep dive into CoffeeScripts semantics from simple functions up through closures, higher-order functions, objects, classes, combinators, and decorators. By <a href="http://braythwayt.com/">Reg Braithwaite</a>.</li>
<li><a href="https://efendibooks.com/minibooks/testing-with-coffeescript">Testing with CoffeeScript</a> is a succinct and freely downloadable guide to building testable applications with CoffeeScript and Jasmine.</li>
<li><a href="http://www.packtpub.com/coffeescript-application-development/book">CoffeeScript Application Development</a> from Packt, introduces CoffeeScript while walking through the process of building a demonstration web application. A <a href="https://www.packtpub.com/web-development/coffeescript-application-development-cookbook">CoffeeScript Application Development Coookbook</a> with over 90 “recipes” is also available.</li>
<li><a href="http://www.manning.com/lee/">CoffeeScript in Action</a> from Manning Publications, covers CoffeeScript syntax, composition techniques and application development.</li>
<li><a href="http://www.dpunkt.de/buecher/4021/coffeescript.html">CoffeeScript: Die Alternative zu JavaScript</a> from dpunkt.verlag, is the first CoffeeScript book in Deutsch.</li>
<li><a href="https://www.packtpub.com/web-development/coffeescript-application-development">CoffeeScript Application Development</a> from Packt, introduces CoffeeScript while walking through the process of building a demonstration web application. A <a href="https://www.packtpub.com/web-development/coffeescript-application-development-cookbook">CoffeeScript Application Development Coookbook</a> with over 90 “recipes” is also available.</li>
<li><a href="https://www.manning.com/books/coffeescript-in-action">CoffeeScript in Action</a> from Manning Publications, covers CoffeeScript syntax, composition techniques and application development.</li>
<li><a href="https://www.dpunkt.de/buecher/4021/coffeescript.html">CoffeeScript: Die Alternative zu JavaScript</a> from dpunkt.verlag, is the first CoffeeScript book in Deutsch.</li>
</ul>
</section>
<section id="screencasts">
<h2>Screencasts</h2>
<ul>
<li><a href="http://coffeescript.codeschool.com">A Sip of CoffeeScript</a> is a <a href="http://www.codeschool.com">Code School Course</a> which combines 6 screencasts with in-browser coding to make learning fun. The first level is free to try out.</li>
<li><a href="http://peepcode.com/products/coffeescript">Meet CoffeeScript</a> is a 75-minute long screencast by <a href="http://peepcode.com/">PeepCode</a>. Highly memorable for its animations which demonstrate transforming CoffeeScript into the equivalent JS.</li>
<li><a href="http://coffeescript.codeschool.com/">A Sip of CoffeeScript</a> is a <a href="https://www.codeschool.com">Code School Course</a> which combines 6 screencasts with in-browser coding to make learning fun. The first level is free to try out.</li>
<li><a href="https://www.pluralsight.com/courses/meet-coffeescript">Meet CoffeeScript</a> is a 75-minute long screencast by PeepCode, now <a href="https://www.pluralsight.com/">PluralSight</a>. Highly memorable for its animations which demonstrate transforming CoffeeScript into the equivalent JS.</li>
<li>If youre looking for less of a time commitment, RailsCasts <a href="http://railscasts.com/episodes/267-coffeescript-basics">CoffeeScript Basics</a> should have you covered, hitting all of the important notes about CoffeeScript in 11 minutes.</li>
</ul>
@ -3109,10 +3113,9 @@ The CoffeeScript logo is available in SVG for use in presentations.</li>
<h2>Examples</h2>
<p>The <a href="https://github.com/trending?l=coffeescript&amp;since=monthly">best list of open-source CoffeeScript examples</a> can be found on GitHub. But just to throw out a few more:</p>
<ul>
<li><strong>GitHub</strong>s <a href="http://hubot.github.com/">Hubot</a>, a friendly IRC robot that can perform any number of useful and useless tasks.</li>
<li><strong>GitHub</strong>s <a href="https://hubot.github.com/">Hubot</a>, a friendly IRC robot that can perform any number of useful and useless tasks.</li>
<li><strong>sstephenson</strong>s <a href="http://pow.cx/">Pow</a>, a zero-configuration Rack server, with comprehensive annotated source.</li>
<li><strong>technoweenie</strong>s <a href="https://github.com/technoweenie/coffee-resque">Coffee-Resque</a>, a port of <a href="https://github.com/defunkt/resque">Resque</a> for Node.js.</li>
<li><strong>assaf</strong>s <a href="http://zombie.labnotes.org/">Zombie.js</a>, a headless, full-stack, faux-browser testing library for Node.js.</li>
<li><strong>stephank</strong>s <a href="https://github.com/stephank/orona">Orona</a>, a remake of the Bolo tank game for modern browsers.</li>
<li><strong>GitHub</strong>s <a href="https://atom.io/">Atom</a>, a hackable text editor built on web technologies.</li>
<li><strong>Basecamp</strong>s <a href="https://trix-editor.org/">Trix</a>, a rich text editor for web apps.</li>
@ -3709,7 +3712,7 @@ six = -&gt;
<a href="https://github.com/jashkenas/coffeescript/compare/1.5.0...1.6.1">1.6.1</a>
<span class="timestamp"> &mdash; <time datetime="2013-03-05">March 5, 2013</time></span>
</h2><ul>
<li>First release of <a href="#source-maps">source maps</a>. Pass the <code>--map</code> flag to the compiler, and off you go. Direct all your thanks over to <a href="http://github.com/jwalton">Jason Walton</a>.</li>
<li>First release of <a href="#source-maps">source maps</a>. Pass the <code>--map</code> flag to the compiler, and off you go. Direct all your thanks over to <a href="https://github.com/jwalton">Jason Walton</a>.</li>
<li>Fixed a 1.5.0 regression with multiple implicit calls against an indented implicit object. Combinations of implicit function calls and implicit objects should generally be parsed better now — but it still isnt good <em>style</em> to nest them too heavily.</li>
<li><code>.coffee.md</code> is now also supported as a Literate CoffeeScript file extension, for existing tooling. <code>.litcoffee</code> remains the canonical one.</li>
<li>Several minor fixes surrounding member properties, bound methods and <code>super</code> in class declarations.</li>
@ -3816,7 +3819,7 @@ six = -&gt;
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.9.4...0.9.5">0.9.5</a>
<span class="timestamp"> &mdash; <time datetime="2010-11-21">November 21, 2010</time></span>
</h2><p>0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from <strong>satyr</strong>s <a href="http://github.com/satyr/coco">Coco</a> dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. <code>undefined</code> now works like <code>null</code>, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: <code>result = i for i in list</code>
</h2><p>0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from <strong>satyr</strong>s <a href="https://github.com/satyr/coco">Coco</a> dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. <code>undefined</code> now works like <code>null</code>, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: <code>result = i for i in list</code>
used to parse as <code>result = (i for i in list)</code> by default … it now parses as
<code>(result = i) for i in list</code>.</p>
<div class="anchor" id="0.9.4"></div>
@ -3883,7 +3886,7 @@ used to parse as <code>result = (i for i in list)</code> by default … it now p
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.4...0.5.5">0.5.5</a>
<span class="timestamp"> &mdash; <time datetime="2010-03-08">March 8, 2010</time></span>
</h2><p>String interpolation, contributed by <a href="http://github.com/StanAngeloff">Stan Angeloff</a>. Since <code>--run</code> has been the default since <strong>0.5.3</strong>, updating <code>--stdio</code> and <code>--eval</code> to run by default, pass <code>--compile</code> as well if youd like to print the result.</p>
</h2><p>String interpolation, contributed by <a href="https://github.com/StanAngeloff">Stan Angeloff</a>. Since <code>--run</code> has been the default since <strong>0.5.3</strong>, updating <code>--stdio</code> and <code>--eval</code> to run by default, pass <code>--compile</code> as well if youd like to print the result.</p>
<div class="anchor" id="0.5.4"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.3...0.5.4">0.5.4</a>
@ -3899,7 +3902,7 @@ used to parse as <code>result = (i for i in list)</code> by default … it now p
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.1...0.5.2">0.5.2</a>
<span class="timestamp"> &mdash; <time datetime="2010-02-25">February 25, 2010</time></span>
</h2><p>Added a compressed version of the compiler for inclusion in web pages as
<code>v2/browser-compiler/coffeescript.js</code>. Itll automatically run any script tags with type <code>text/coffeescript</code> for you. Added a <code>--stdio</code> option to the <code>coffee</code> command, for piped-in compiles.</p>
<code>/v2/browser-compiler/coffeescript.js</code>. Itll automatically run any script tags with type <code>text/coffeescript</code> for you. Added a <code>--stdio</code> option to the <code>coffee</code> command, for piped-in compiles.</p>
<div class="anchor" id="0.5.1"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.5.0...0.5.1">0.5.1</a>
@ -3965,7 +3968,7 @@ The <code>extends</code> keyword now functions identically to <code>goog.inherit
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.6...0.2.0">0.2.0</a>
<span class="timestamp"> &mdash; <time datetime="2010-01-05">January 5, 2010</time></span>
</h2><p>Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to <a href="http://github.com/liamoc">Liam OConnor-Davis</a> for whitespace and expression help.</p>
</h2><p>Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to <a href="https://github.com/liamoc">Liam OConnor-Davis</a> for whitespace and expression help.</p>
<div class="anchor" id="0.1.6"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.5...0.1.6">0.1.6</a>
@ -3980,7 +3983,7 @@ The <code>extends</code> keyword now functions identically to <code>goog.inherit
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.3...0.1.4">0.1.4</a>
<span class="timestamp"> &mdash; <time datetime="2009-12-25">December 25, 2009</time></span>
</h2><p>The official CoffeeScript extension is now <code>.coffee</code> instead of <code>.cs</code>, which properly belongs to <a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a>. Due to popular demand, you can now also use <code>=</code> to assign. Unlike JavaScript, <code>=</code> can also be used within object literals, interchangeably with <code>:</code>. Made a grammatical fix for chained function calls like <code>func(1)(2)(3)(4)</code>. Inheritance and super no longer use <code>__proto__</code>, so they should be IE-compatible now.</p>
</h2><p>The official CoffeeScript extension is now <code>.coffee</code> instead of <code>.cs</code>, which properly belongs to <a href="https://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a>. Due to popular demand, you can now also use <code>=</code> to assign. Unlike JavaScript, <code>=</code> can also be used within object literals, interchangeably with <code>:</code>. Made a grammatical fix for chained function calls like <code>func(1)(2)(3)(4)</code>. Inheritance and super no longer use <code>__proto__</code>, so they should be IE-compatible now.</p>
<div class="anchor" id="0.1.3"></div>
<h2 class="header">
<a href="https://github.com/jashkenas/coffeescript/compare/0.1.2...0.1.3">0.1.3</a>

View File

@ -2,12 +2,12 @@
There are a number of excellent resources to help you get started with CoffeeScript, some of which are freely available online.
* [The Little Book on CoffeeScript](http://arcturo.github.com/library/coffeescript/) is a brief 5-chapter introduction to CoffeeScript, written with great clarity and precision by [Alex MacCaw](http://alexmaccaw.co.uk/).
* [Smooth CoffeeScript](http://autotelicum.github.com/Smooth-CoffeeScript/) is a reimagination of the excellent book [Eloquent JavaScript](http://eloquentjavascript.net/), as if it had been written in CoffeeScript instead. Covers language features as well as the functional and object oriented programming styles. By [E. Hoigaard](https://github.com/autotelicum).
* [The Little Book on CoffeeScript](http://arcturo.github.io/library/coffeescript/) is a brief 5-chapter introduction to CoffeeScript, written with great clarity and precision by [Alex MacCaw](http://alexmaccaw.co.uk/).
* [Smooth CoffeeScript](http://autotelicum.github.io/Smooth-CoffeeScript/) is a reimagination of the excellent book [Eloquent JavaScript](http://eloquentjavascript.net/), as if it had been written in CoffeeScript instead. Covers language features as well as the functional and object oriented programming styles. By [E. Hoigaard](https://github.com/autotelicum).
* [CoffeeScript: Accelerated JavaScript Development](http://pragprog.com/book/tbcoffee/coffeescript) is [Trevor Burnham](http://trevorburnham.com/)s thorough introduction to the language. By the end of the book, youll have built a fast-paced multiplayer word game, writing both the client-side and Node.js portions in CoffeeScript.
* [CoffeeScript Programming with jQuery, Rails, and Node.js](http://www.packtpub.com/coffeescript-programming-with-jquery-rails-nodejs/book) is a new book by Michael Erasmus that covers CoffeeScript with an eye towards real-world usage both in the browser (jQuery) and on the server-side (Rails, Node).
* [CoffeeScript Programming with jQuery, Rails, and Node.js](https://www.packtpub.com/web-development/coffeescript-programming-jquery-rails-and-nodejs) is a new book by Michael Erasmus that covers CoffeeScript with an eye towards real-world usage both in the browser (jQuery) and on the server-side (Rails, Node).
* [CoffeeScript Ristretto](https://leanpub.com/coffeescript-ristretto/read) is a deep dive into CoffeeScripts semantics from simple functions up through closures, higher-order functions, objects, classes, combinators, and decorators. By [Reg Braithwaite](http://braythwayt.com/).
* [Testing with CoffeeScript](https://efendibooks.com/minibooks/testing-with-coffeescript) is a succinct and freely downloadable guide to building testable applications with CoffeeScript and Jasmine.
* [CoffeeScript Application Development](http://www.packtpub.com/coffeescript-application-development/book) from Packt, introduces CoffeeScript while walking through the process of building a demonstration web application. A [CoffeeScript Application Development Coookbook](https://www.packtpub.com/web-development/coffeescript-application-development-cookbook) with over 90 “recipes” is also available.
* [CoffeeScript in Action](http://www.manning.com/lee/) from Manning Publications, covers CoffeeScript syntax, composition techniques and application development.
* [CoffeeScript: Die Alternative zu JavaScript](http://www.dpunkt.de/buecher/4021/coffeescript.html) from dpunkt.verlag, is the first CoffeeScript book in Deutsch.
* [CoffeeScript Application Development](https://www.packtpub.com/web-development/coffeescript-application-development) from Packt, introduces CoffeeScript while walking through the process of building a demonstration web application. A [CoffeeScript Application Development Coookbook](https://www.packtpub.com/web-development/coffeescript-application-development-cookbook) with over 90 “recipes” is also available.
* [CoffeeScript in Action](https://www.manning.com/books/coffeescript-in-action) from Manning Publications, covers CoffeeScript syntax, composition techniques and application development.
* [CoffeeScript: Die Alternative zu JavaScript](https://www.dpunkt.de/buecher/4021/coffeescript.html) from dpunkt.verlag, is the first CoffeeScript book in Deutsch.

View File

@ -241,7 +241,7 @@ releaseHeader('2013-03-18', '1.6.2', '1.6.1')
releaseHeader('2013-03-05', '1.6.1', '1.5.0')
```
* First release of [source maps](#source-maps). Pass the `--map` flag to the compiler, and off you go. Direct all your thanks over to [Jason Walton](http://github.com/jwalton).
* First release of [source maps](#source-maps). Pass the `--map` flag to the compiler, and off you go. Direct all your thanks over to [Jason Walton](https://github.com/jwalton).
* Fixed a 1.5.0 regression with multiple implicit calls against an indented implicit object. Combinations of implicit function calls and implicit objects should generally be parsed better now — but it still isnt good _style_ to nest them too heavily.
* `.coffee.md` is now also supported as a Literate CoffeeScript file extension, for existing tooling. `.litcoffee` remains the canonical one.
* Several minor fixes surrounding member properties, bound methods and `super` in class declarations.
@ -348,7 +348,7 @@ The REPL now properly formats stacktraces, and stays alive through asynchronous
releaseHeader('2010-11-21', '0.9.5', '0.9.4')
```
0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from **satyr**s [Coco](http://github.com/satyr/coco) dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. `undefined` now works like `null`, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: `result = i for i in list`
0.9.5 should be considered the first release candidate for CoffeeScript 1.0. There have been a large number of internal changes since the previous release, many contributed from **satyr**s [Coco](https://github.com/satyr/coco) dialect of CoffeeScript. Heregexes (extended regexes) were added. Functions can now have default arguments. Class bodies are now executable code. Improved syntax errors for invalid CoffeeScript. `undefined` now works like `null`, and cannot be assigned a new value. There was a precedence change with respect to single-line comprehensions: `result = i for i in list`
used to parse as `result = (i for i in list)` by default … it now parses as
`(result = i) for i in list`.
@ -428,7 +428,7 @@ Interpolation can now be used within regular expressions and heredocs, as well a
releaseHeader('2010-03-08', '0.5.5', '0.5.4')
```
String interpolation, contributed by [Stan Angeloff](http://github.com/StanAngeloff). Since `--run` has been the default since **0.5.3**, updating `--stdio` and `--eval` to run by default, pass `--compile` as well if youd like to print the result.
String interpolation, contributed by [Stan Angeloff](https://github.com/StanAngeloff). Since `--run` has been the default since **0.5.3**, updating `--stdio` and `--eval` to run by default, pass `--compile` as well if youd like to print the result.
```
releaseHeader('2010-03-03', '0.5.4', '0.5.3')
@ -447,7 +447,7 @@ releaseHeader('2010-02-25', '0.5.2', '0.5.1')
```
Added a compressed version of the compiler for inclusion in web pages as
`v<%= majorVersion %>/browser-compiler/coffeescript.js`. Itll automatically run any script tags with type `text/coffeescript` for you. Added a `--stdio` option to the `coffee` command, for piped-in compiles.
`/v<%= majorVersion %>/browser-compiler/coffeescript.js`. Itll automatically run any script tags with type `text/coffeescript` for you. Added a `--stdio` option to the `coffee` command, for piped-in compiles.
```
releaseHeader('2010-02-24', '0.5.1', '0.5.0')
@ -524,7 +524,7 @@ Arguments objects are now converted into real arrays when referenced.
releaseHeader('2010-01-05', '0.2.0', '0.1.6')
```
Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to [Liam OConnor-Davis](http://github.com/liamoc) for whitespace and expression help.
Major release. Significant whitespace. Better statement-to-expression conversion. Splats. Splice literals. Object comprehensions. Blocks. The existential operator. Many thanks to all the folks who posted issues, with special thanks to [Liam OConnor-Davis](https://github.com/liamoc) for whitespace and expression help.
```
releaseHeader('2009-12-27', '0.1.6', '0.1.5')
@ -542,7 +542,7 @@ Array slice literals and array comprehensions can now both take Ruby-style range
releaseHeader('2009-12-25', '0.1.4', '0.1.3')
```
The official CoffeeScript extension is now `.coffee` instead of `.cs`, which properly belongs to [C#](http://en.wikipedia.org/wiki/C_Sharp_(programming_language)). Due to popular demand, you can now also use `=` to assign. Unlike JavaScript, `=` can also be used within object literals, interchangeably with `:`. Made a grammatical fix for chained function calls like `func(1)(2)(3)(4)`. Inheritance and super no longer use `__proto__`, so they should be IE-compatible now.
The official CoffeeScript extension is now `.coffee` instead of `.cs`, which properly belongs to [C#](https://en.wikipedia.org/wiki/C_Sharp_(programming_language)). Due to popular demand, you can now also use `=` to assign. Unlike JavaScript, `=` can also be used within object literals, interchangeably with `:`. Made a grammatical fix for chained function calls like `func(1)(2)(3)(4)`. Inheritance and super no longer use `__proto__`, so they should be IE-compatible now.
```
releaseHeader('2009-12-25', '0.1.3', '0.1.2')

View File

@ -1,6 +1,6 @@
## Chained Comparisons
CoffeeScript borrows [chained comparisons](http://docs.python.org/reference/expressions.html#notin) from Python — making it easy to test if a value falls within a certain range.
CoffeeScript borrows [chained comparisons](https://docs.python.org/3/reference/expressions.html#not-in) from Python — making it easy to test if a value falls within a certain range.
```
codeFor('comparisons', 'healthy')

View File

@ -2,10 +2,9 @@
The [best list of open-source CoffeeScript examples](https://github.com/trending?l=coffeescript&since=monthly) can be found on GitHub. But just to throw out a few more:
* **GitHub**s [Hubot](http://hubot.github.com/), a friendly IRC robot that can perform any number of useful and useless tasks.
* **GitHub**s [Hubot](https://hubot.github.com/), a friendly IRC robot that can perform any number of useful and useless tasks.
* **sstephenson**s [Pow](http://pow.cx/), a zero-configuration Rack server, with comprehensive annotated source.
* **technoweenie**s [Coffee-Resque](https://github.com/technoweenie/coffee-resque), a port of [Resque](https://github.com/defunkt/resque) for Node.js.
* **assaf**s [Zombie.js](http://zombie.labnotes.org/), a headless, full-stack, faux-browser testing library for Node.js.
* **stephank**s [Orona](https://github.com/stephank/orona), a remake of the Bolo tank game for modern browsers.
* **GitHub**s [Atom](https://atom.io/), a hackable text editor built on web technologies.
* **Basecamp**s [Trix](https://trix-editor.org/), a rich text editor for web apps.

View File

@ -12,6 +12,9 @@ If we had used `->` in the callback above, `@customer` would have referred to th
When used in a class definition, methods declared with the fat arrow will be automatically bound to each instance of the class when the instance is constructed.
<div id="generator-functions" class="bookmark"></div>
<div id="async-functions" class="bookmark"></div>
CoffeeScript also supports [generator functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) and [async functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) through the `yield` and `await` keywords respectively. There's no `function*(){}` or `async function(){}` nonsense — a generator in CoffeeScript is simply a function that yields, and an async function in CoffeeScript is simply a function that awaits.
```
@ -20,6 +23,8 @@ codeFor('generators', 'ps.next().value')
`yield*` is called `yield from`, and `yield return` may be used if you need to force a generator that doesnt yield.
<div id="generator-iteration" class="bookmark"></div>
You can iterate over a generator function using `for…from`.
```

View File

@ -1,8 +1,8 @@
## Installation
The command-line version of `coffee` is available as a [Node.js](http://nodejs.org/) utility. The [core compiler](/v<%= majorVersion %>/browser-compiler/coffeescript.js) however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see [Try CoffeeScript](#try)).
The command-line version of `coffee` is available as a [Node.js](https://nodejs.org/) utility. The [core compiler](/v<%= majorVersion %>/browser-compiler/coffeescript.js) however, does not depend on Node, and can be run in any JavaScript environment, or in the browser (see [Try CoffeeScript](#try)).
To install, first make sure you have a working copy of the latest stable version of [Node.js](http://nodejs.org/). You can then install CoffeeScript globally with [npm](http://npmjs.org):
To install, first make sure you have a working copy of the latest stable version of [Node.js](https://nodejs.org/). You can then install CoffeeScript globally with [npm](https://www.npmjs.com/):
```bash
npm install --global coffeescript@next

View File

@ -2,7 +2,7 @@
The golden rule of CoffeeScript is: _“Its just JavaScript.”_ 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.
**Latest Version:** [<%= fullVersion %>](http://github.com/jashkenas/coffeescript/tarball/<%= fullVersion %>)
**Latest Version:** [<%= fullVersion %>](https://github.com/jashkenas/coffeescript/tarball/<%= fullVersion %>)
```bash
npm install -g coffeescript@next

View File

@ -2,4 +2,4 @@
Besides being used as an ordinary programming language, CoffeeScript may also be written in “literate” mode. If you name your file with a `.litcoffee` extension, you can write it as a Markdown document — a document that also happens to be executable CoffeeScript code. The compiler will treat any indented blocks (Markdowns way of indicating source code) as code, and ignore the rest as comments.
Just for kicks, a little bit of the compiler is currently implemented in this fashion: See it [as a document](https://gist.github.com/jashkenas/3fc3c1a8b1009c00d9df), [raw](https://raw.github.com/jashkenas/coffeescript/master/src/scope.litcoffee), and [properly highlighted in a text editor](http://cl.ly/LxEu).
Just for kicks, a little bit of the compiler is currently implemented in this fashion: See it [as a document](https://gist.github.com/jashkenas/3fc3c1a8b1009c00d9df), [raw](https://raw.githubusercontent.com/jashkenas/coffeescript/master/src/scope.litcoffee), and [properly highlighted in a text editor](http://cl.ly/LxEu).

View File

@ -6,6 +6,8 @@ ES2015 modules are supported in CoffeeScript, with very similar `import` and `ex
codeFor('modules')
```
<div id="modules-note" class="bookmark"></div>
Note that the CoffeeScript compiler **does not resolve modules**; writing an `import` or `export` statement in CoffeeScript will produce an `import` or `export` statement in the resulting output. It is your responsibility attach another transpiler, such as [Traceur Compiler](https://github.com/google/traceur-compiler), [Babel](http://babeljs.io/) or [Rollup](https://github.com/rollup/rollup), to convert this ES2015 syntax into code that will work in your target runtimes.
Also note that any file with an `import` or `export` statement will be output without a [top-level function safety wrapper](#lexical-scope); in other words, importing or exporting modules will automatically trigger [bare](#usage) mode for that file. This is because per the ES2015 spec, `import` or `export` statements must occur at the topmost scope.

View File

@ -16,7 +16,7 @@ As a shortcut for `this.property`, you can use `@property`.
You can use `in` to test for array presence, and `of` to test for JavaScript object-key presence.
To simplify math expressions, `**` can be used for exponentiation and `//` performs integer division. `%` works just like in JavaScript, while `%%` provides [“dividend dependent modulo”](http://en.wikipedia.org/wiki/Modulo_operation):
To simplify math expressions, `**` can be used for exponentiation and `//` performs integer division. `%` works just like in JavaScript, while `%%` provides [“dividend dependent modulo”](https://en.wikipedia.org/wiki/Modulo_operation):
```
codeFor('modulo')

View File

@ -1,13 +1,13 @@
## Resources
* [CoffeeScript on GitHub](http://github.com/jashkenas/coffeescript/)
* [CoffeeScript Issues](http://github.com/jashkenas/coffeescript/issues)<br>
* [CoffeeScript on GitHub](https://github.com/jashkenas/coffeescript/)
* [CoffeeScript Issues](https://github.com/jashkenas/coffeescript/issues)<br>
Bug reports, feature proposals, and ideas for changes to the language belong here.
* [CoffeeScript Google Group](https://groups.google.com/forum/#!forum/coffeescript)<br>
If youd like to ask a question, the mailing list is a good place to get help.
* [The CoffeeScript Wiki](http://github.com/jashkenas/coffeescript/wiki)<br>
If youve ever learned a neat CoffeeScript tip or trick, or ran into a gotcha — share it on the wiki. The wiki also serves as a directory of handy [text editor extensions](http://github.com/jashkenas/coffeescript/wiki/Text-editor-plugins), [web framework plugins](http://github.com/jashkenas/coffeescript/wiki/Web-framework-plugins), and general [CoffeeScript build tools](http://github.com/jashkenas/coffeescript/wiki/Build-tools).
* [The FAQ](http://github.com/jashkenas/coffeescript/wiki/FAQ)<br>
* [The CoffeeScript Wiki](https://github.com/jashkenas/coffeescript/wiki)<br>
If youve ever learned a neat CoffeeScript tip or trick, or ran into a gotcha — share it on the wiki. The wiki also serves as a directory of handy [text editor extensions](https://github.com/jashkenas/coffeescript/wiki/Text-editor-plugins), [web framework plugins](https://github.com/jashkenas/coffeescript/wiki/Web-framework-plugins), and general [CoffeeScript build tools](https://github.com/jashkenas/coffeescript/wiki/Build-tools).
* [The FAQ](https://github.com/jashkenas/coffeescript/wiki/FAQ)<br>
Perhaps your CoffeeScript-related question has been asked before. Check the FAQ first.
* [JS2Coffee](http://js2.coffee/)<br>
Is a very well done reverse JavaScript-to-CoffeeScript compiler. Its not going to be perfect (infer what your JavaScript classes are, when you need bound functions, and so on…) — but its a great starting point for converting simple scripts.

View File

@ -1,5 +1,5 @@
## Screencasts
* [A Sip of CoffeeScript](http://coffeescript.codeschool.com) is a [Code School Course](http://www.codeschool.com) which combines 6 screencasts with in-browser coding to make learning fun. The first level is free to try out.
* [Meet CoffeeScript](http://peepcode.com/products/coffeescript) is a 75-minute long screencast by [PeepCode](http://peepcode.com/). Highly memorable for its animations which demonstrate transforming CoffeeScript into the equivalent JS.
* [A Sip of CoffeeScript](http://coffeescript.codeschool.com/) is a [Code School Course](https://www.codeschool.com) which combines 6 screencasts with in-browser coding to make learning fun. The first level is free to try out.
* [Meet CoffeeScript](https://www.pluralsight.com/courses/meet-coffeescript) is a 75-minute long screencast by PeepCode, now [PluralSight](https://www.pluralsight.com/). Highly memorable for its animations which demonstrate transforming CoffeeScript into the equivalent JS.
* If youre looking for less of a time commitment, RailsCasts [CoffeeScript Basics](http://railscasts.com/episodes/267-coffeescript-basics) should have you covered, hitting all of the important notes about CoffeeScript in 11 minutes.

View File

@ -1,6 +1,6 @@
## `"text/coffeescript"` Script Tags
While its not recommended for serious use, CoffeeScripts may be included directly within the browser using `<script type="text/coffeescript">` tags. The source includes a compressed and minified version of the compiler ([Download current version here, 51k when gzipped](/v<%= majorVersion %>/browser-compiler/coffeescript.js)) as `v<%= majorVersion %>/browser-compiler/coffeescript.js`. Include this file on a page with inline CoffeeScript tags, and it will compile and evaluate them in order.
While its not recommended for serious use, CoffeeScripts may be included directly within the browser using `<script type="text/coffeescript">` tags. The source includes a compressed and minified version of the compiler ([Download current version here, 51k when gzipped](/v<%= majorVersion %>/browser-compiler/coffeescript.js)) as `docs/v<%= majorVersion %>/browser-compiler/coffeescript.js`. Include this file on a page with inline CoffeeScript tags, and it will compile and evaluate them in order.
In fact, the little bit of glue script that runs [Try CoffeeScript](#try), as well as the code examples and other interactive parts of this site, is implemented in just this way. View source and look at the bottom of the page to see the example. Including the script also gives you access to `CoffeeScript.compile()` so you can pop open your JavaScript console and try compiling some strings.

View File

@ -2,4 +2,4 @@
CoffeeScript includes support for generating source maps, a way to tell your JavaScript engine what part of your CoffeeScript program matches up with the code being evaluated. Browsers that support it can automatically use source maps to show your original source code in the debugger. To generate source maps alongside your JavaScript files, pass the `--map` or `-m` flag to the compiler.
For a full introduction to source maps, how they work, and how to hook them up in your browser, read the [HTML5 Tutorial](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/).
For a full introduction to source maps, how they work, and how to hook them up in your browser, read the [HTML5 Tutorial](https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/).

View File

@ -64,18 +64,18 @@
Annotated Source
</div>
<div class="contents menu">
<a href="v<%= majorVersion %>/annotated-source/grammar.html">Grammar Rules — src/grammar</a>
<a href="v<%= majorVersion %>/annotated-source/lexer.html">Lexing Tokens — src/lexer</a>
<a href="v<%= majorVersion %>/annotated-source/rewriter.html">The Rewriter — src/rewriter</a>
<a href="v<%= majorVersion %>/annotated-source/nodes.html">The Syntax Tree — src/nodes</a>
<a href="v<%= majorVersion %>/annotated-source/scope.html">Lexical Scope — src/scope</a>
<a href="v<%= majorVersion %>/annotated-source/helpers.html">Helpers &amp; Utility Functions — src/helpers</a>
<a href="v<%= majorVersion %>/annotated-source/coffeescript.html">The CoffeeScript Module — src/coffeescript</a>
<a href="v<%= majorVersion %>/annotated-source/cake.html">Cake &amp; Cakefiles — src/cake</a>
<a href="v<%= majorVersion %>/annotated-source/command.html">“coffee” Command-Line Utility — src/command</a>
<a href="v<%= majorVersion %>/annotated-source/optparse.html">Option Parsing — src/optparse</a>
<a href="v<%= majorVersion %>/annotated-source/repl.html">Interactive REPL — src/repl</a>
<a href="v<%= majorVersion %>/annotated-source/sourcemap.html">Source Maps — src/sourcemap</a>
<a href="/v<%= majorVersion %>/annotated-source/grammar.html">Grammar Rules — src/grammar</a>
<a href="/v<%= majorVersion %>/annotated-source/lexer.html">Lexing Tokens — src/lexer</a>
<a href="/v<%= majorVersion %>/annotated-source/rewriter.html">The Rewriter — src/rewriter</a>
<a href="/v<%= majorVersion %>/annotated-source/nodes.html">The Syntax Tree — src/nodes</a>
<a href="/v<%= majorVersion %>/annotated-source/scope.html">Lexical Scope — src/scope</a>
<a href="/v<%= majorVersion %>/annotated-source/helpers.html">Helpers &amp; Utility Functions — src/helpers</a>
<a href="/v<%= majorVersion %>/annotated-source/coffee-script.html">The CoffeeScript Module — src/coffee-script</a>
<a href="/v<%= majorVersion %>/annotated-source/cake.html">Cake &amp; Cakefiles — src/cake</a>
<a href="/v<%= majorVersion %>/annotated-source/command.html">“coffee” Command-Line Utility — src/command</a>
<a href="/v<%= majorVersion %>/annotated-source/optparse.html">Option Parsing — src/optparse</a>
<a href="/v<%= majorVersion %>/annotated-source/repl.html">Interactive REPL — src/repl</a>
<a href="/v<%= majorVersion %>/annotated-source/sourcemap.html">Source Maps — src/sourcemap</a>
</div>
</div>
</div>

View File

@ -1,5 +1,5 @@
# `cake` is a simplified version of [Make](http://www.gnu.org/software/make/)
# ([Rake](http://rake.rubyforge.org/), [Jake](http://github.com/280north/jake))
# ([Rake](http://rake.rubyforge.org/), [Jake](https://github.com/280north/jake))
# for CoffeeScript. You define tasks with names and descriptions in a Cakefile,
# and can call them from the command line, or invoke them from other tasks.
#

View File

@ -1,14 +1,14 @@
# The CoffeeScript parser is generated by [Jison](http://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
# style to [Bison](http://www.gnu.org/software/bison), implemented in JavaScript.
# It can recognize [LALR(1), LR(0), SLR(1), and LR(1)](http://en.wikipedia.org/wiki/LR_grammar)
# It can recognize [LALR(1), LR(0), SLR(1), and LR(1)](https://en.wikipedia.org/wiki/LR_grammar)
# type grammars. To create the Jison parser, we list the pattern to match
# on the left-hand side, and the action to take (usually the creation of syntax
# tree nodes) on the right. As the parser runs, it
# shifts tokens from our token stream, from left to right, and
# [attempts to match](http://en.wikipedia.org/wiki/Bottom-up_parsing)
# [attempts to match](https://en.wikipedia.org/wiki/Bottom-up_parsing)
# the token sequence against the rules below. When a match can be made, it
# reduces into the [nonterminal](http://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols)
# reduces into the [nonterminal](https://en.wikipedia.org/wiki/Terminal_and_nonterminal_symbols)
# (the enclosing name at the top), and we proceed from there.
#
# If you run the `cake build:parser` command, Jison constructs a parse table
@ -26,7 +26,7 @@
unwrap = /^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/
# Our handy DSL for Jison grammar generation, thanks to
# [Tim Caswell](http://github.com/creationix). For every rule in the grammar,
# [Tim Caswell](https://github.com/creationix). For every rule in the grammar,
# we pass the pattern-defining string, the action to run, and extra options,
# optionally. If no action is specified, we simply pass the value of the
# previous nonterminal.

View File

@ -6,7 +6,7 @@
# [tag, value, locationData]
#
# where locationData is {first_line, first_column, last_line, last_column}, which is a
# format that can be fed directly into [Jison](http://github.com/zaach/jison). These
# format that can be fed directly into [Jison](https://github.com/zaach/jison). These
# are read by jison in the `parser.lexer` function defined in coffeescript.coffee.
{Rewriter, INVERSES} = require './rewriter'

View File

@ -2487,7 +2487,7 @@ exports.Op = class Op extends Base
not @isNumber()
# Am I capable of
# [Python-style comparison chaining](http://docs.python.org/reference/expressions.html#notin)?
# [Python-style comparison chaining](https://docs.python.org/3/reference/expressions.html#not-in)?
isChainable: ->
@operator in ['<', '>', '>=', '<=', '===', '!==']

View File

@ -136,7 +136,7 @@ Base64 VLQ Encoding
Note that SourceMap VLQ encoding is "backwards". MIDI-style VLQ encoding puts
the most-significant-bit (MSB) from the original value into the MSB of the VLQ
encoded value (see [Wikipedia](http://en.wikipedia.org/wiki/File:Uintvar_coding.svg)).
encoded value (see [Wikipedia](https://en.wikipedia.org/wiki/File:Uintvar_coding.svg)).
SourceMap VLQ does things the other way around, with the least significat four
bits of the original value encoded into the first byte of the VLQ encoded value.