1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
This commit is contained in:
Geoffrey Booth 2021-09-19 14:15:00 -07:00 committed by GitHub
parent ff13d85625
commit f9c3316aa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 10194 additions and 8390 deletions

View file

@ -11,38 +11,34 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest, macos-latest, windows-latest]
node-version: [6.x, 8.x, 10.x, 12.x, 14.x, 16.x]
node-version: [10.x, 12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
# Puppeteer runs an install script that requires Node 10+.
# Also, the `npm ci` command doesnt exist on the version of npm that shipped with Node 6.
- run: node --eval "pjson = JSON.parse(require('fs').readFileSync('./package.json')); delete pjson.devDependencies.puppeteer; require('fs').writeFileSync('./package.json', JSON.stringify(pjson), 'utf8')"
if: matrix.node-version == '6.x' || matrix.node-version == '8.x'
- run: npm install
if: matrix.node-version == '6.x'
- run: npm ci
if: matrix.node-version != '6.x'
- run: node ./bin/cake test
- run: node --harmony ./bin/cake test
- run: node ./bin/cake test:browser
if: matrix.node-version != '6.x' && matrix.node-version != '8.x'
- run: node ./bin/cake test:browser:node
- run: node ./bin/cake test:integrations
# Ensure that we can still build in the current version of Node
- run: node ./bin/cake build:except-parser
- run: node ./bin/cake build:parser
- run: node ./bin/cake build:full
# Build twice to ensure that the latest build of the compiler can still build itself
- run: node ./bin/cake build:except-parser
- run: node ./bin/cake build:parser
# Build the browser compiler for the headless browser test
- run: node ./bin/cake build:browser
# Check that the git diff is clean, to ensure that the updated build output was committed
- run: git diff --exit-code
if: matrix.node-version != '6.x' && matrix.node-version != '8.x'
# Build test.html, so that test:browser uses the latest tests
- run: node ./bin/cake doc:test
# Test
- run: node ./bin/cake test
- run: node ./bin/cake test:browser
- run: node ./bin/cake test:browser:node
- run: node ./bin/cake test:integrations

View file

@ -222,11 +222,11 @@ buildDocs = (watch = no) ->
markdownRenderer = require('markdown-it')
html: yes
typographer: yes
highlight: (str, lang) ->
highlight: (str, language) ->
# From https://github.com/markdown-it/markdown-it#syntax-highlighting
if lang and hljs.getLanguage(lang)
if language and hljs.getLanguage(language)
try
return hljs.highlight(lang, str).value
return hljs.highlight(str, { language }).value
catch ex
return '' # No syntax highlighting
@ -502,7 +502,7 @@ task 'test:browser', 'run the test suite against the modern browser compiler in
# version of the browser compiler. Theres no reason to run this test in old
# versions of Node (the runtime is the headless Chrome browser, not Node),
# and Puppeteer 3 only supports Node >= 10.18.1, so limit this test to those
# versions. The code below uses `Promise.prototype.finally` because the
# versions. The code below uses `Promise.prototype.finally` because the
# CoffeeScript codebase currently maintains compatibility with Node 6, which
# did not support `async`/`await` syntax. Even though this test doesnt run
# in Node 6, it needs to still _parse_ in Node 6 so that this file can load.
@ -537,7 +537,7 @@ task 'test:browser', 'run the test suite against the modern browser compiler in
page = pageHandle
page.goto 'http://localhost:8080/'
).then(->
page.waitFor '#result',
page.waitForSelector '#result',
visible: yes
polling: 'mutation'
).then((element) ->
@ -548,7 +548,7 @@ task 'test:browser', 'run the test suite against the modern browser compiler in
browser.close()
).finally ->
server.close()
if result and 'failed' not in result
if result and not result.includes('failed')
log result, green
else
log result, red
@ -570,6 +570,9 @@ task 'test:integrations', 'test the module integrated with other libraries and e
# can be built by such tools; if such a build succeeds, it verifies that no
# Node modules are required as part of the compiler (as opposed to the tests)
# and that therefore the compiler will run in a browser environment.
# Webpack 5 requires Node >= 10.13.0.
[major, minor] = process.versions.node.split('.').map (n) -> parseInt(n, 10)
return if major < 10 or (major is 10 and minor < 13)
tmpdir = os.tmpdir()
webpack = require 'webpack'
webpack {
@ -594,7 +597,7 @@ task 'test:integrations', 'test the module integrated with other libraries and e
process.exit 1
builtCompiler = path.join tmpdir, 'coffeescript.js'
CoffeeScript = require builtCompiler
{ CoffeeScript } = require builtCompiler
global.testingBrowser = yes
testResults = runTests CoffeeScript
fs.unlinkSync builtCompiler

View file

@ -112,8 +112,8 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
<p>This <strong>Browser</strong> compatibility layer extends core CoffeeScript functions
to make things work smoothly when compiling code directly in the browser.
@ -123,7 +123,7 @@ We add support for loading remote Coffee scripts via <strong>XHR</strong>, and
</div>
<div class="content"><div class='highlight'><pre>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./coffeescript&#x27;</span>
{ compile } = CoffeeScript</pre></div></div>
</li>
@ -132,8 +132,8 @@ CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-stri
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>Use <code>window.eval</code> to evaluate code, rather than just <code>eval</code>, to run the
script in a clean global scope rather than inheriting the scope of the
@ -142,10 +142,10 @@ use either <code>window.eval</code> or <code>global.eval</code> as appropriate).
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="hljs-built_in">eval</span> = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
options.bare ?= <span class="hljs-literal">on</span>
globalRoot = <span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>? <span class="hljs-keyword">then</span> <span class="hljs-built_in">window</span> <span class="hljs-keyword">else</span> <span class="hljs-built_in">global</span>
globalRoot[<span class="hljs-string">'eval'</span>] compile code, options</pre></div></div>
globalRoot = <span class="hljs-keyword">if</span> window? <span class="hljs-keyword">then</span> window <span class="hljs-keyword">else</span> global
globalRoot[<span class="hljs-string">&#x27;eval&#x27;</span>] compile code, options</pre></div></div>
</li>
@ -153,8 +153,8 @@ use either <code>window.eval</code> or <code>global.eval</code> as appropriate).
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>Running code does not provide access to this scope.</p>
@ -163,7 +163,7 @@ use either <code>window.eval</code> or <code>global.eval</code> as appropriate).
<div class="content"><div class='highlight'><pre>CoffeeScript.run = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
options.bare = <span class="hljs-literal">on</span>
options.shiftLine = <span class="hljs-literal">on</span>
Function(compile code, options)()</pre></div></div>
<span class="hljs-built_in">Function</span>(compile code, options)()</pre></div></div>
</li>
@ -171,15 +171,15 @@ use either <code>window.eval</code> or <code>global.eval</code> as appropriate).
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Export this more limited <code>CoffeeScript</code> than what is exported by
<code>index.coffee</code>, which is intended for a Node environment.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">module</span>.exports = CoffeeScript</pre></div></div>
<div class="content"><div class='highlight'><pre>module.<span class="hljs-built_in">exports</span> = CoffeeScript</pre></div></div>
</li>
@ -187,14 +187,14 @@ use either <code>window.eval</code> or <code>global.eval</code> as appropriate).
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>If were not in a browser environment, were finished with the public API.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> <span class="hljs-built_in">window</span>?</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> window?</pre></div></div>
</li>
@ -202,8 +202,8 @@ use either <code>window.eval</code> or <code>global.eval</code> as appropriate).
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Include source maps where possible. If weve got a base64 encoder, a
JSON serializer, and tools for escaping unicode characters, were good to go.
@ -211,7 +211,7 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> btoa? <span class="hljs-keyword">and</span> JSON?
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> btoa? <span class="hljs-keyword">and</span> <span class="hljs-built_in">JSON</span>?
<span class="hljs-function"> <span class="hljs-title">compile</span> = <span class="hljs-params">(code, options = {})</span> -&gt;</span>
options.inlineMap = <span class="hljs-literal">true</span>
CoffeeScript.compile code, options</pre></div></div>
@ -222,8 +222,8 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Load a remote script from the current domain via XHR.</p>
@ -231,19 +231,19 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
<div class="content"><div class='highlight'><pre>CoffeeScript.load = <span class="hljs-function"><span class="hljs-params">(url, callback, options = {}, hold = <span class="hljs-literal">false</span>)</span> -&gt;</span>
options.sourceFiles = [url]
xhr = <span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.ActiveXObject
<span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.ActiveXObject(<span class="hljs-string">'Microsoft.XMLHTTP'</span>)
xhr = <span class="hljs-keyword">if</span> window.ActiveXObject
<span class="hljs-keyword">new</span> window.ActiveXObject(<span class="hljs-string">&#x27;Microsoft.XMLHTTP&#x27;</span>)
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">new</span> <span class="hljs-built_in">window</span>.XMLHttpRequest()
xhr.open <span class="hljs-string">'GET'</span>, url, <span class="hljs-literal">true</span>
xhr.overrideMimeType <span class="hljs-string">'text/plain'</span> <span class="hljs-keyword">if</span> <span class="hljs-string">'overrideMimeType'</span> <span class="hljs-keyword">of</span> xhr
<span class="hljs-keyword">new</span> window.XMLHttpRequest()
xhr.open <span class="hljs-string">&#x27;GET&#x27;</span>, url, <span class="hljs-literal">true</span>
xhr.overrideMimeType <span class="hljs-string">&#x27;text/plain&#x27;</span> <span class="hljs-keyword">if</span> <span class="hljs-string">&#x27;overrideMimeType&#x27;</span> <span class="hljs-keyword">of</span> xhr
xhr.onreadystatechange = <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">if</span> xhr.readyState <span class="hljs-keyword">is</span> <span class="hljs-number">4</span>
<span class="hljs-keyword">if</span> xhr.status <span class="hljs-keyword">in</span> [<span class="hljs-number">0</span>, <span class="hljs-number">200</span>]
param = [xhr.responseText, options]
CoffeeScript.run param... <span class="hljs-keyword">unless</span> hold
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Could not load <span class="hljs-subst">#{url}</span>"</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;Could not load <span class="hljs-subst">#{url}</span>&quot;</span>
callback param <span class="hljs-keyword">if</span> callback
xhr.send <span class="hljs-literal">null</span></pre></div></div>
@ -253,8 +253,8 @@ Ported from <a href="https://developer.mozilla.org/en-US/docs/DOM/window.btoa">h
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Activate CoffeeScript in the browser by having it compile and evaluate
all script tags with a content-type of <code>text/coffeescript</code>.
@ -263,14 +263,14 @@ This happens on page load.</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.runScripts = <span class="hljs-function">-&gt;</span>
scripts = <span class="hljs-built_in">window</span>.<span class="hljs-built_in">document</span>.getElementsByTagName <span class="hljs-string">'script'</span>
coffeetypes = [<span class="hljs-string">'text/coffeescript'</span>, <span class="hljs-string">'text/literate-coffeescript'</span>]
scripts = window.document.getElementsByTagName <span class="hljs-string">&#x27;script&#x27;</span>
coffeetypes = [<span class="hljs-string">&#x27;text/coffeescript&#x27;</span>, <span class="hljs-string">&#x27;text/literate-coffeescript&#x27;</span>]
coffees = (s <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> scripts <span class="hljs-keyword">when</span> s.type <span class="hljs-keyword">in</span> coffeetypes)
index = <span class="hljs-number">0</span>
<span class="hljs-function">
<span class="hljs-title">execute</span> = -&gt;</span>
param = coffees[index]
<span class="hljs-keyword">if</span> param <span class="hljs-keyword">instanceof</span> Array
<span class="hljs-keyword">if</span> param <span class="hljs-keyword">instanceof</span> <span class="hljs-built_in">Array</span>
CoffeeScript.run param...
index++
execute()
@ -278,7 +278,7 @@ This happens on page load.</p>
<span class="hljs-keyword">for</span> script, i <span class="hljs-keyword">in</span> coffees
<span class="hljs-keyword">do</span> (script, i) -&gt;
options = literate: script.type <span class="hljs-keyword">is</span> coffeetypes[<span class="hljs-number">1</span>]
source = script.src <span class="hljs-keyword">or</span> script.getAttribute(<span class="hljs-string">'data-src'</span>)
source = script.src <span class="hljs-keyword">or</span> script.getAttribute(<span class="hljs-string">&#x27;data-src&#x27;</span>)
<span class="hljs-keyword">if</span> source
options.filename = source
CoffeeScript.load source,
@ -295,8 +295,8 @@ This happens on page load.</p>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p><code>options.filename</code> defines the filename the source map appears as
in Developer Tools. If a script tag has an <code>id</code>, use that as the
@ -306,8 +306,8 @@ only one CoffeeScript script block to parse.</p>
</div>
<div class="content"><div class='highlight'><pre> options.filename = <span class="hljs-keyword">if</span> script.id <span class="hljs-keyword">and</span> script.id <span class="hljs-keyword">isnt</span> <span class="hljs-string">''</span> <span class="hljs-keyword">then</span> script.id <span class="hljs-keyword">else</span> <span class="hljs-string">"coffeescript<span class="hljs-subst">#{<span class="hljs-keyword">if</span> i <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> i <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>}</span>"</span>
options.sourceFiles = [<span class="hljs-string">'embedded'</span>]
<div class="content"><div class='highlight'><pre> options.filename = <span class="hljs-keyword">if</span> script.id <span class="hljs-keyword">and</span> script.id <span class="hljs-keyword">isnt</span> <span class="hljs-string">&#x27;&#x27;</span> <span class="hljs-keyword">then</span> script.id <span class="hljs-keyword">else</span> <span class="hljs-string">&quot;coffeescript<span class="hljs-subst">#{<span class="hljs-keyword">if</span> i <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> i <span class="hljs-keyword">else</span> <span class="hljs-string">&#x27;&#x27;</span>}</span>&quot;</span>
options.sourceFiles = [<span class="hljs-string">&#x27;embedded&#x27;</span>]
coffees[i] = [script.innerHTML, options]
execute()</pre></div></div>
@ -318,8 +318,8 @@ only one CoffeeScript script block to parse.</p>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>Listen for window load, both in decent browsers and in IE.
Only attach this event handler on startup for the
@ -329,11 +329,11 @@ be importable without side effects.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">is</span> <span class="hljs-built_in">window</span>
<span class="hljs-keyword">if</span> <span class="hljs-built_in">window</span>.addEventListener
<span class="hljs-built_in">window</span>.addEventListener <span class="hljs-string">'DOMContentLoaded'</span>, CoffeeScript.runScripts, <span class="hljs-literal">no</span>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> this <span class="hljs-keyword">is</span> window
<span class="hljs-keyword">if</span> window.addEventListener
window.addEventListener <span class="hljs-string">&#x27;DOMContentLoaded&#x27;</span>, CoffeeScript.runScripts, <span class="hljs-literal">no</span>
<span class="hljs-keyword">else</span>
<span class="hljs-built_in">window</span>.attachEvent <span class="hljs-string">'onload'</span>, CoffeeScript.runScripts</pre></div></div>
window.attachEvent <span class="hljs-string">&#x27;onload&#x27;</span>, CoffeeScript.runScripts</pre></div></div>
</li>

View file

@ -112,8 +112,8 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</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="https://github.com/280north/jake">Jake</a>)
@ -130,18 +130,18 @@ current directorys Cakefile.</p>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>External dependencies.</p>
</div>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">'./optparse'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./'</span></pre></div></div>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;fs&#x27;</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;path&#x27;</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./helpers&#x27;</span>
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./optparse&#x27;</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./&#x27;</span></pre></div></div>
</li>
@ -149,8 +149,8 @@ CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-stri
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>Register .coffee extension</p>
@ -164,8 +164,8 @@ CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-stri
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Keep track of the list of defined tasks, the accepted options, and so on.</p>
@ -182,14 +182,14 @@ oparse = <span class="hljs-literal">null</span></pre></div></div>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>Mixin the top-level Cake functions for Cakefiles to use directly.</p>
</div>
<div class="content"><div class='highlight'><pre>helpers.extend <span class="hljs-built_in">global</span>,</pre></div></div>
<div class="content"><div class='highlight'><pre>helpers.extend global,</pre></div></div>
</li>
@ -197,8 +197,8 @@ oparse = <span class="hljs-literal">null</span></pre></div></div>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Define a Cake task with a short name, an optional sentence description,
and the function to run as the action itself.</p>
@ -215,8 +215,8 @@ and the function to run as the action itself.</p>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Define an option that the Cakefile accepts. The parsed options hash,
containing all of the command-line options passed, will be made available
@ -233,8 +233,8 @@ as the first argument to the action.</p>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Invoke another task in the current Cakefile.</p>
@ -250,8 +250,8 @@ as the first argument to the action.</p>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p>Run <code>cake</code>. Executes all of the tasks you pass, in order. Note that Nodes
asynchrony may cause tasks to execute in a different order than youd expect.
@ -260,17 +260,17 @@ original directory name, when running Cake tasks from subdirectories.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function">-&gt;</span>
<span class="hljs-built_in">global</span>.__originalDirname = fs.realpathSync <span class="hljs-string">'.'</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.run = <span class="hljs-function">-&gt;</span>
global.__originalDirname = fs.realpathSync <span class="hljs-string">&#x27;.&#x27;</span>
process.chdir cakefileDirectory __originalDirname
args = process.argv[<span class="hljs-number">2.</span>.]
CoffeeScript.run fs.readFileSync(<span class="hljs-string">'Cakefile'</span>).toString(), filename: <span class="hljs-string">'Cakefile'</span>
CoffeeScript.run fs.readFileSync(<span class="hljs-string">&#x27;Cakefile&#x27;</span>).toString(), filename: <span class="hljs-string">&#x27;Cakefile&#x27;</span>
oparse = <span class="hljs-keyword">new</span> optparse.OptionParser switches
<span class="hljs-keyword">return</span> printTasks() <span class="hljs-keyword">unless</span> args.length
<span class="hljs-keyword">try</span>
options = oparse.parse(args)
<span class="hljs-keyword">catch</span> e
<span class="hljs-keyword">return</span> fatalError <span class="hljs-string">"<span class="hljs-subst">#{e}</span>"</span>
<span class="hljs-keyword">return</span> fatalError <span class="hljs-string">&quot;<span class="hljs-subst">#{e}</span>&quot;</span>
invoke arg <span class="hljs-keyword">for</span> arg <span class="hljs-keyword">in</span> options.arguments</pre></div></div>
</li>
@ -279,8 +279,8 @@ original directory name, when running Cake tasks from subdirectories.</p>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>Display the list of Cake tasks in a format similar to <code>rake -T</code></p>
@ -288,14 +288,14 @@ original directory name, when running Cake tasks from subdirectories.</p>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">printTasks</span> = -&gt;</span>
relative = path.relative <span class="hljs-keyword">or</span> path.resolve
cakefilePath = path.join relative(__originalDirname, process.cwd()), <span class="hljs-string">'Cakefile'</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"<span class="hljs-subst">#{cakefilePath}</span> defines the following tasks:\n"</span>
cakefilePath = path.join relative(__originalDirname, process.cwd()), <span class="hljs-string">&#x27;Cakefile&#x27;</span>
console.log <span class="hljs-string">&quot;<span class="hljs-subst">#{cakefilePath}</span> defines the following tasks:\n&quot;</span>
<span class="hljs-keyword">for</span> name, task <span class="hljs-keyword">of</span> tasks
spaces = <span class="hljs-number">20</span> - name.length
spaces = <span class="hljs-keyword">if</span> spaces &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> Array(spaces + <span class="hljs-number">1</span>).join(<span class="hljs-string">' '</span>) <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
desc = <span class="hljs-keyword">if</span> task.description <span class="hljs-keyword">then</span> <span class="hljs-string">"# <span class="hljs-subst">#{task.description}</span>"</span> <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"cake <span class="hljs-subst">#{name}</span><span class="hljs-subst">#{spaces}</span> <span class="hljs-subst">#{desc}</span>"</span>
<span class="hljs-built_in">console</span>.log oparse.help() <span class="hljs-keyword">if</span> switches.length</pre></div></div>
spaces = <span class="hljs-keyword">if</span> spaces &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> <span class="hljs-built_in">Array</span>(spaces + <span class="hljs-number">1</span>).join(<span class="hljs-string">&#x27; &#x27;</span>) <span class="hljs-keyword">else</span> <span class="hljs-string">&#x27;&#x27;</span>
desc = <span class="hljs-keyword">if</span> task.description <span class="hljs-keyword">then</span> <span class="hljs-string">&quot;# <span class="hljs-subst">#{task.description}</span>&quot;</span> <span class="hljs-keyword">else</span> <span class="hljs-string">&#x27;&#x27;</span>
console.log <span class="hljs-string">&quot;cake <span class="hljs-subst">#{name}</span><span class="hljs-subst">#{spaces}</span> <span class="hljs-subst">#{desc}</span>&quot;</span>
console.log oparse.help() <span class="hljs-keyword">if</span> switches.length</pre></div></div>
</li>
@ -303,19 +303,19 @@ original directory name, when running Cake tasks from subdirectories.</p>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>Print an error and exit when attempting to use an invalid task/option.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">fatalError</span> = <span class="hljs-params">(message)</span> -&gt;</span>
<span class="hljs-built_in">console</span>.error message + <span class="hljs-string">'\n'</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">'To see a list of all tasks/options, run "cake"'</span>
console.error message + <span class="hljs-string">&#x27;\n&#x27;</span>
console.log <span class="hljs-string">&#x27;To see a list of all tasks/options, run &quot;cake&quot;&#x27;</span>
process.exit <span class="hljs-number">1</span>
<span class="hljs-function">
<span class="hljs-title">missingTask</span> = <span class="hljs-params">(task)</span> -&gt;</span> fatalError <span class="hljs-string">"No such task: <span class="hljs-subst">#{task}</span>"</span></pre></div></div>
<span class="hljs-title">missingTask</span> = <span class="hljs-params">(task)</span> -&gt;</span> fatalError <span class="hljs-string">&quot;No such task: <span class="hljs-subst">#{task}</span>&quot;</span></pre></div></div>
</li>
@ -323,8 +323,8 @@ original directory name, when running Cake tasks from subdirectories.</p>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>When <code>cake</code> is invoked, search in the current and all parent directories
to find the relevant Cakefile.</p>
@ -332,10 +332,10 @@ to find the relevant Cakefile.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">cakefileDirectory</span> = <span class="hljs-params">(dir)</span> -&gt;</span>
<span class="hljs-keyword">return</span> dir <span class="hljs-keyword">if</span> fs.existsSync path.join dir, <span class="hljs-string">'Cakefile'</span>
parent = path.normalize path.join dir, <span class="hljs-string">'..'</span>
<span class="hljs-keyword">return</span> dir <span class="hljs-keyword">if</span> fs.existsSync path.join dir, <span class="hljs-string">&#x27;Cakefile&#x27;</span>
parent = path.normalize path.join dir, <span class="hljs-string">&#x27;..&#x27;</span>
<span class="hljs-keyword">return</span> cakefileDirectory parent <span class="hljs-keyword">unless</span> parent <span class="hljs-keyword">is</span> dir
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Cakefile not found in <span class="hljs-subst">#{process.cwd()}</span>"</span></pre></div></div>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;Cakefile not found in <span class="hljs-subst">#{process.cwd()}</span>&quot;</span></pre></div></div>
</li>

View file

@ -112,8 +112,8 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
<p>CoffeeScript can be used both on the server, as a command-line compiler based
on Node.js/V8, or to run CoffeeScript directly in the browser. This module
@ -123,10 +123,10 @@ source CoffeeScript into JavaScript.</p>
</div>
<div class="content"><div class='highlight'><pre>
{Lexer} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./lexer'</span>
{parser} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./parser'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
SourceMap = <span class="hljs-built_in">require</span> <span class="hljs-string">'./sourcemap'</span></pre></div></div>
{Lexer} = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./lexer&#x27;</span>
{parser} = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./parser&#x27;</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./helpers&#x27;</span>
SourceMap = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./sourcemap&#x27;</span></pre></div></div>
</li>
@ -134,15 +134,15 @@ SourceMap = <span class="hljs-built_in">require</span> <span class="hljs-str
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>Require <code>package.json</code>, which is two levels above this file, as this file is
evaluated from <code>lib/coffeescript</code>.</p>
</div>
<div class="content"><div class='highlight'><pre>packageJson = <span class="hljs-built_in">require</span> <span class="hljs-string">'../../package.json'</span></pre></div></div>
<div class="content"><div class='highlight'><pre>packageJson = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;../../package.json&#x27;</span></pre></div></div>
</li>
@ -150,16 +150,16 @@ evaluated from <code>lib/coffeescript</code>.</p>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>The current CoffeeScript version number.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.VERSION = packageJson.version
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.VERSION = packageJson.version
exports.FILE_EXTENSIONS = FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'</span>, <span class="hljs-string">'.litcoffee'</span>, <span class="hljs-string">'.coffee.md'</span>]</pre></div></div>
<span class="hljs-built_in">exports</span>.FILE_EXTENSIONS = FILE_EXTENSIONS = [<span class="hljs-string">&#x27;.coffee&#x27;</span>, <span class="hljs-string">&#x27;.litcoffee&#x27;</span>, <span class="hljs-string">&#x27;.coffee.md&#x27;</span>]</pre></div></div>
</li>
@ -167,14 +167,14 @@ exports.FILE_EXTENSIONS = FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Expose helpers for testing.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.helpers = helpers</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.helpers = helpers</pre></div></div>
</li>
@ -182,17 +182,17 @@ exports.FILE_EXTENSIONS = FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>Function that allows for btoa in both nodejs and the browser.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">base64encode</span> = <span class="hljs-params">(src)</span> -&gt;</span> <span class="hljs-keyword">switch</span>
<span class="hljs-keyword">when</span> <span class="hljs-keyword">typeof</span> Buffer <span class="hljs-keyword">is</span> <span class="hljs-string">'function'</span>
Buffer.<span class="hljs-keyword">from</span>(src).toString(<span class="hljs-string">'base64'</span>)
<span class="hljs-keyword">when</span> <span class="hljs-keyword">typeof</span> btoa <span class="hljs-keyword">is</span> <span class="hljs-string">'function'</span></pre></div></div>
<span class="hljs-keyword">when</span> <span class="hljs-keyword">typeof</span> Buffer <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;function&#x27;</span>
Buffer.<span class="hljs-keyword">from</span>(src).toString(<span class="hljs-string">&#x27;base64&#x27;</span>)
<span class="hljs-keyword">when</span> <span class="hljs-keyword">typeof</span> btoa <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;function&#x27;</span></pre></div></div>
</li>
@ -200,8 +200,8 @@ exports.FILE_EXTENSIONS = FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>The contents of a <code>&lt;script&gt;</code> block are encoded via UTF-16, so if any extended
characters are used in the block, btoa will fail as it maxes out at UTF-8.
@ -210,10 +210,10 @@ for the gory details, and for the solution implemented here.</p>
</div>
<div class="content"><div class='highlight'><pre> btoa encodeURIComponent(src).replace <span class="hljs-regexp">/%([0-9A-F]{2})/g</span>, <span class="hljs-function"><span class="hljs-params">(match, p1)</span> -&gt;</span>
String.fromCharCode <span class="hljs-string">'0x'</span> + p1
<div class="content"><div class='highlight'><pre> btoa <span class="hljs-built_in">encodeURIComponent</span>(src).replace <span class="hljs-regexp">/%([0-9A-F]{2})/g</span>, <span class="hljs-function"><span class="hljs-params">(match, p1)</span> -&gt;</span>
<span class="hljs-built_in">String</span>.fromCharCode <span class="hljs-string">&#x27;0x&#x27;</span> + p1
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error(<span class="hljs-string">'Unable to base64 encode inline sourcemap.'</span>)</pre></div></div>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">&#x27;Unable to base64 encode inline sourcemap.&#x27;</span>)</pre></div></div>
</li>
@ -221,8 +221,8 @@ for the gory details, and for the solution implemented here.</p>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Function wrapper to add source file information to SyntaxErrors thrown by the
lexer/parser/compiler.</p>
@ -234,7 +234,7 @@ lexer/parser/compiler.</p>
<span class="hljs-keyword">try</span>
fn.call @, code, options
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'string'</span> <span class="hljs-comment"># Support `CoffeeScript.nodes(tokens)`.</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">&#x27;string&#x27;</span> <span class="hljs-comment"># Support `CoffeeScript.nodes(tokens)`.</span>
<span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, code, options.filename</pre></div></div>
</li>
@ -243,8 +243,8 @@ lexer/parser/compiler.</p>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>For each compiled file, save its source in memory in case we need to
recompile it later. We might need to recompile if the first compilation
@ -264,8 +264,8 @@ its not likely to be used. Save in form of <code>filename</code>: [<code>(sou
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p>Also save source maps if generated, in form of <code>(source)</code>: [<code>(source map)</code>].</p>
@ -279,8 +279,8 @@ its not likely to be used. Save in form of <code>filename</code>: [<code>(sou
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>This is exported to enable an external module to implement caching of
compilation results. When the compiled js source is loaded from cache, the
@ -290,7 +290,7 @@ corresponding file (the source map will be generated on demand).</p>
</div>
<div class="content"><div class='highlight'><pre>exports.registerCompiled = registerCompiled = <span class="hljs-function"><span class="hljs-params">(filename, source, sourcemap)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.registerCompiled = registerCompiled = <span class="hljs-function"><span class="hljs-params">(filename, source, sourcemap)</span> -&gt;</span>
sources[filename] ?= []
sources[filename].push source
@ -305,8 +305,8 @@ corresponding file (the source map will be generated on demand).</p>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>Compile CoffeeScript code to JavaScript, using the Coffee/Jison compiler.</p>
<p>If <code>options.sourceMap</code> is specified, then <code>options.filename</code> must also be
@ -319,7 +319,7 @@ doing programmatic lookups.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.compile = compile = withPrettyErrors (code, options = {}) -&gt;</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.compile = compile = withPrettyErrors (code, options = {}) -&gt;</pre></div></div>
</li>
@ -327,14 +327,14 @@ doing programmatic lookups.</p>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>Clone <code>options</code>, to avoid mutating the <code>options</code> object passed in.</p>
</div>
<div class="content"><div class='highlight'><pre> options = Object.assign {}, options</pre></div></div>
<div class="content"><div class='highlight'><pre> options = <span class="hljs-built_in">Object</span>.assign {}, options</pre></div></div>
</li>
@ -342,8 +342,8 @@ doing programmatic lookups.</p>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-13">&#x00a7;</a>
</div>
<p>Always generate a source map if no filename is passed in, since without a
a filename we have no way to retrieve this source later in the event that
@ -352,7 +352,7 @@ we need to recompile it to get a source map for <code>prepareStackTrace</code>.<
</div>
<div class="content"><div class='highlight'><pre> generateSourceMap = options.sourceMap <span class="hljs-keyword">or</span> options.inlineMap <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> options.filename?
filename = options.filename <span class="hljs-keyword">or</span> <span class="hljs-string">'&lt;anonymous&gt;'</span>
filename = options.filename <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span>
checkShebangLine filename, code
@ -366,8 +366,8 @@ we need to recompile it to get a source map for <code>prepareStackTrace</code>.<
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-14">&#x00a7;</a>
</div>
<p>Pass a list of referenced variables, so that generated variables wont get
the same name.</p>
@ -375,7 +375,7 @@ the same name.</p>
</div>
<div class="content"><div class='highlight'><pre> options.referencedVars = (
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'IDENTIFIER'</span>
token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;IDENTIFIER&#x27;</span>
)</pre></div></div>
</li>
@ -384,8 +384,8 @@ the same name.</p>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-15">&#x00a7;</a>
</div>
<p>Check for import or export; if found, force bare mode.</p>
@ -393,7 +393,7 @@ the same name.</p>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> options.bare? <span class="hljs-keyword">and</span> options.bare <span class="hljs-keyword">is</span> <span class="hljs-literal">yes</span>
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens
<span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'IMPORT'</span>, <span class="hljs-string">'EXPORT'</span>]
<span class="hljs-keyword">if</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;IMPORT&#x27;</span>, <span class="hljs-string">&#x27;EXPORT&#x27;</span>]
options.bare = <span class="hljs-literal">yes</span>
<span class="hljs-keyword">break</span>
@ -405,8 +405,8 @@ the same name.</p>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-16">&#x00a7;</a>
</div>
<p>If all that was requested was a POJO representation of the nodes, e.g.
the abstract syntax tree (AST), we can stop now and just return that
@ -418,7 +418,7 @@ which mightve gotten misaligned from the original source due to the
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> options.ast
nodes.allCommentTokens = helpers.extractAllCommentTokens tokens
sourceCodeNumberOfLines = (code.match(<span class="hljs-regexp">/\r?\n/g</span>) <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>).length + <span class="hljs-number">1</span>
sourceCodeNumberOfLines = (code.match(<span class="hljs-regexp">/\r?\n/g</span>) <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;&#x27;</span>).length + <span class="hljs-number">1</span>
sourceCodeLastLine = <span class="hljs-regexp">/.*$/</span>.exec(code)[<span class="hljs-number">0</span>] <span class="hljs-comment"># `.*` matches all but line break characters.</span>
ast = nodes.ast options
range = [<span class="hljs-number">0</span>, code.length]
@ -437,7 +437,7 @@ which mightve gotten misaligned from the original source due to the
currentLine += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> options.header
currentLine += <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> options.shiftLine
currentColumn = <span class="hljs-number">0</span>
js = <span class="hljs-string">""</span>
js = <span class="hljs-string">&quot;&quot;</span>
<span class="hljs-keyword">for</span> fragment <span class="hljs-keyword">in</span> fragments</pre></div></div>
</li>
@ -446,8 +446,8 @@ which mightve gotten misaligned from the original source due to the
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-17">&#x00a7;</a>
</div>
<p>Update the sourcemap with data from each fragment.</p>
@ -461,8 +461,8 @@ which mightve gotten misaligned from the original source due to the
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-18">&#x00a7;</a>
</div>
<p>Do not include empty, whitespace, or semicolon-only fragments.</p>
@ -473,10 +473,10 @@ which mightve gotten misaligned from the original source due to the
[fragment.locationData.first_line, fragment.locationData.first_column]
[currentLine, currentColumn]
{noReplace: <span class="hljs-literal">true</span>})
newLines = helpers.count fragment.code, <span class="hljs-string">"\n"</span>
newLines = helpers.count fragment.code, <span class="hljs-string">&quot;\n&quot;</span>
currentLine += newLines
<span class="hljs-keyword">if</span> newLines
currentColumn = fragment.code.length - (fragment.code.lastIndexOf(<span class="hljs-string">"\n"</span>) + <span class="hljs-number">1</span>)
currentColumn = fragment.code.length - (fragment.code.lastIndexOf(<span class="hljs-string">&quot;\n&quot;</span>) + <span class="hljs-number">1</span>)
<span class="hljs-keyword">else</span>
currentColumn += fragment.code.length</pre></div></div>
@ -486,8 +486,8 @@ which mightve gotten misaligned from the original source due to the
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-19">&#x00a7;</a>
</div>
<p>Copy the code from each fragment into the final JavaScript.</p>
@ -496,14 +496,14 @@ which mightve gotten misaligned from the original source due to the
<div class="content"><div class='highlight'><pre> js += fragment.code
<span class="hljs-keyword">if</span> options.header
header = <span class="hljs-string">"Generated by CoffeeScript <span class="hljs-subst">#{@VERSION}</span>"</span>
js = <span class="hljs-string">"// <span class="hljs-subst">#{header}</span>\n<span class="hljs-subst">#{js}</span>"</span>
header = <span class="hljs-string">&quot;Generated by CoffeeScript <span class="hljs-subst">#{@VERSION}</span>&quot;</span>
js = <span class="hljs-string">&quot;// <span class="hljs-subst">#{header}</span>\n<span class="hljs-subst">#{js}</span>&quot;</span>
<span class="hljs-keyword">if</span> generateSourceMap
v3SourceMap = map.generate options, code
<span class="hljs-keyword">if</span> options.transpile
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> options.transpile <span class="hljs-keyword">isnt</span> <span class="hljs-string">'object'</span></pre></div></div>
<span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> options.transpile <span class="hljs-keyword">isnt</span> <span class="hljs-string">&#x27;object&#x27;</span></pre></div></div>
</li>
@ -511,15 +511,15 @@ which mightve gotten misaligned from the original source due to the
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-20">&#x00a7;</a>
</div>
<p>This only happens if run via the Node API and <code>transpile</code> is set to
something other than an object.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">'The transpile option must be given an object with options to pass to Babel'</span></pre></div></div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&#x27;The transpile option must be given an object with options to pass to Babel&#x27;</span></pre></div></div>
</li>
@ -527,8 +527,8 @@ something other than an object.</p>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-21">&#x00a7;</a>
</div>
<p>Get the reference to Babel that we have been passed if this compiler
is run via the CLI or Node API.</p>
@ -538,7 +538,7 @@ is run via the CLI or Node API.</p>
<div class="content"><div class='highlight'><pre> transpiler = options.transpile.transpile
<span class="hljs-keyword">delete</span> options.transpile.transpile
transpilerOptions = Object.assign {}, options.transpile</pre></div></div>
transpilerOptions = <span class="hljs-built_in">Object</span>.assign {}, options.transpile</pre></div></div>
</li>
@ -546,8 +546,8 @@ is run via the CLI or Node API.</p>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-22">&#x00a7;</a>
</div>
<p>See <a href="https://github.com/babel/babel/issues/827#issuecomment-77573107">https://github.com/babel/babel/issues/827#issuecomment-77573107</a>:
Babel can take a v3 source map object as input in <code>inputSourceMap</code>
@ -563,10 +563,10 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
v3SourceMap = transpilerOutput.map
<span class="hljs-keyword">if</span> options.inlineMap
encoded = base64encode JSON.stringify v3SourceMap
sourceMapDataURI = <span class="hljs-string">"//# sourceMappingURL=data:application/json;base64,<span class="hljs-subst">#{encoded}</span>"</span>
sourceURL = <span class="hljs-string">"//# sourceURL=<span class="hljs-subst">#{options.filename ? <span class="hljs-string">'coffeescript'</span>}</span>"</span>
js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n<span class="hljs-subst">#{sourceMapDataURI}</span>\n<span class="hljs-subst">#{sourceURL}</span>"</span>
encoded = base64encode <span class="hljs-built_in">JSON</span>.stringify v3SourceMap
sourceMapDataURI = <span class="hljs-string">&quot;//# sourceMappingURL=data:application/json;base64,<span class="hljs-subst">#{encoded}</span>&quot;</span>
sourceURL = <span class="hljs-string">&quot;//# sourceURL=<span class="hljs-subst">#{options.filename ? <span class="hljs-string">&#x27;coffeescript&#x27;</span>}</span>&quot;</span>
js = <span class="hljs-string">&quot;<span class="hljs-subst">#{js}</span>\n<span class="hljs-subst">#{sourceMapDataURI}</span>\n<span class="hljs-subst">#{sourceURL}</span>&quot;</span>
registerCompiled filename, code, map
@ -574,7 +574,7 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
{
js
sourceMap: map
v3SourceMap: JSON.stringify v3SourceMap, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>
v3SourceMap: <span class="hljs-built_in">JSON</span>.stringify v3SourceMap, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>
}
<span class="hljs-keyword">else</span>
js</pre></div></div>
@ -585,14 +585,14 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-23">&#x00a7;</a>
</div>
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.tokens = withPrettyErrors (code, options) -&gt;
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.tokens = withPrettyErrors (code, options) -&gt;
lexer.tokenize code, options</pre></div></div>
</li>
@ -601,8 +601,8 @@ and it will return an <em>updated</em> v3 source map object in its output.</p>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-24">&#x00a7;</a>
</div>
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
@ -610,8 +610,8 @@ or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.nodes = withPrettyErrors (source, options) -&gt;
source = lexer.tokenize source, options <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> source <span class="hljs-keyword">is</span> <span class="hljs-string">'string'</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.nodes = withPrettyErrors (source, options) -&gt;
source = lexer.tokenize source, options <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> source <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;string&#x27;</span>
parser.parse source</pre></div></div>
</li>
@ -620,8 +620,8 @@ or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-25">&#x00a7;</a>
</div>
<p>This file used to export these methods; leave stubs that throw warnings
instead. These methods have been moved into <code>index.coffee</code> to provide
@ -631,8 +631,8 @@ environment.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.run = exports.eval = exports.register = <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">'require index.coffee, not this file'</span></pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.run = <span class="hljs-built_in">exports</span>.<span class="hljs-built_in">eval</span> = <span class="hljs-built_in">exports</span>.register = <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&#x27;require index.coffee, not this file&#x27;</span></pre></div></div>
</li>
@ -640,8 +640,8 @@ environment.</p>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-26">&#x00a7;</a>
</div>
<p>Instantiate a Lexer for our use here.</p>
@ -655,8 +655,8 @@ environment.</p>
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-27">&#x00a7;</a>
</div>
<p>The real Lexer produces a generic stream of tokens. This object provides a
thin wrapper around it, compatible with the Jison API. We can then pass it
@ -676,12 +676,12 @@ directly as a “Jison lexer.”</p>
parser.errorToken = token.origin <span class="hljs-keyword">or</span> token
@yylineno = @yylloc.first_line
<span class="hljs-keyword">else</span>
tag = <span class="hljs-string">''</span>
tag = <span class="hljs-string">&#x27;&#x27;</span>
tag
setInput: <span class="hljs-function"><span class="hljs-params">(tokens)</span> -&gt;</span>
parser.tokens = tokens
@pos = <span class="hljs-number">0</span>
upcomingInput: <span class="hljs-function">-&gt;</span> <span class="hljs-string">''</span></pre></div></div>
upcomingInput: <span class="hljs-function">-&gt;</span> <span class="hljs-string">&#x27;&#x27;</span></pre></div></div>
</li>
@ -689,14 +689,14 @@ directly as a “Jison lexer.”</p>
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-28">&#x00a7;</a>
</div>
<p>Make all the AST nodes visible to the parser.</p>
</div>
<div class="content"><div class='highlight'><pre>parser.yy = <span class="hljs-built_in">require</span> <span class="hljs-string">'./nodes'</span></pre></div></div>
<div class="content"><div class='highlight'><pre>parser.yy = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./nodes&#x27;</span></pre></div></div>
</li>
@ -704,8 +704,8 @@ directly as a “Jison lexer.”</p>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-29">&#x00a7;</a>
</div>
<p>Override Jisons default error handling function.</p>
@ -719,8 +719,8 @@ directly as a “Jison lexer.”</p>
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-30">&#x00a7;</a>
</div>
<p>Disregard Jisons message, it contains redundant line number information.
Disregard the token, we take its value directly from the lexer in case
@ -733,11 +733,11 @@ the error is caused by a generated token which might refer to its origin.</p>
errorText = <span class="hljs-keyword">switch</span>
<span class="hljs-keyword">when</span> errorToken <span class="hljs-keyword">is</span> tokens[tokens.length - <span class="hljs-number">1</span>]
<span class="hljs-string">'end of input'</span>
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'INDENT'</span>, <span class="hljs-string">'OUTDENT'</span>]
<span class="hljs-string">'indentation'</span>
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">'IDENTIFIER'</span>, <span class="hljs-string">'NUMBER'</span>, <span class="hljs-string">'INFINITY'</span>, <span class="hljs-string">'STRING'</span>, <span class="hljs-string">'STRING_START'</span>, <span class="hljs-string">'REGEX'</span>, <span class="hljs-string">'REGEX_START'</span>]
errorTag.replace(<span class="hljs-regexp">/_START$/</span>, <span class="hljs-string">''</span>).toLowerCase()
<span class="hljs-string">&#x27;end of input&#x27;</span>
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;INDENT&#x27;</span>, <span class="hljs-string">&#x27;OUTDENT&#x27;</span>]
<span class="hljs-string">&#x27;indentation&#x27;</span>
<span class="hljs-keyword">when</span> errorTag <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;IDENTIFIER&#x27;</span>, <span class="hljs-string">&#x27;NUMBER&#x27;</span>, <span class="hljs-string">&#x27;INFINITY&#x27;</span>, <span class="hljs-string">&#x27;STRING&#x27;</span>, <span class="hljs-string">&#x27;STRING_START&#x27;</span>, <span class="hljs-string">&#x27;REGEX&#x27;</span>, <span class="hljs-string">&#x27;REGEX_START&#x27;</span>]
errorTag.replace(<span class="hljs-regexp">/_START$/</span>, <span class="hljs-string">&#x27;&#x27;</span>).toLowerCase()
<span class="hljs-keyword">else</span>
helpers.nameWhitespaceCharacter errorText</pre></div></div>
@ -747,8 +747,8 @@ the error is caused by a generated token which might refer to its origin.</p>
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-31">&#x00a7;</a>
</div>
<p>The second argument has a <code>loc</code> property, which should have the location
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
@ -757,7 +757,7 @@ from the lexer.</p>
</div>
<div class="content"><div class='highlight'><pre> helpers.throwSyntaxError <span class="hljs-string">"unexpected <span class="hljs-subst">#{errorText}</span>"</span>, errorLoc</pre></div></div>
<div class="content"><div class='highlight'><pre> helpers.throwSyntaxError <span class="hljs-string">&quot;unexpected <span class="hljs-subst">#{errorText}</span>&quot;</span>, errorLoc</pre></div></div>
</li>
@ -765,8 +765,8 @@ from the lexer.</p>
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-32">&#x00a7;</a>
</div>
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
Modified to handle sourceMap</p>
@ -775,18 +775,18 @@ Modified to handle sourceMap</p>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">formatSourcePosition</span> = <span class="hljs-params">(frame, getSourceMapping)</span> -&gt;</span>
filename = <span class="hljs-literal">undefined</span>
fileLocation = <span class="hljs-string">''</span>
fileLocation = <span class="hljs-string">&#x27;&#x27;</span>
<span class="hljs-keyword">if</span> frame.isNative()
fileLocation = <span class="hljs-string">"native"</span>
fileLocation = <span class="hljs-string">&quot;native&quot;</span>
<span class="hljs-keyword">else</span>
<span class="hljs-keyword">if</span> frame.isEval()
filename = frame.getScriptNameOrSourceURL()
fileLocation = <span class="hljs-string">"<span class="hljs-subst">#{frame.getEvalOrigin()}</span>, "</span> <span class="hljs-keyword">unless</span> filename
fileLocation = <span class="hljs-string">&quot;<span class="hljs-subst">#{frame.getEvalOrigin()}</span>, &quot;</span> <span class="hljs-keyword">unless</span> filename
<span class="hljs-keyword">else</span>
filename = frame.getFileName()
filename <span class="hljs-keyword">or</span>= <span class="hljs-string">"&lt;anonymous&gt;"</span>
filename <span class="hljs-keyword">or</span>= <span class="hljs-string">&quot;&lt;anonymous&gt;&quot;</span>
line = frame.getLineNumber()
column = frame.getColumnNumber()</pre></div></div>
@ -797,8 +797,8 @@ Modified to handle sourceMap</p>
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-33">&#x00a7;</a>
</div>
<p>Check for a sourceMap position</p>
@ -807,9 +807,9 @@ Modified to handle sourceMap</p>
<div class="content"><div class='highlight'><pre> source = getSourceMapping filename, line, column
fileLocation =
<span class="hljs-keyword">if</span> source
<span class="hljs-string">"<span class="hljs-subst">#{filename}</span>:<span class="hljs-subst">#{source[<span class="hljs-number">0</span>]}</span>:<span class="hljs-subst">#{source[<span class="hljs-number">1</span>]}</span>"</span>
<span class="hljs-string">&quot;<span class="hljs-subst">#{filename}</span>:<span class="hljs-subst">#{source[<span class="hljs-number">0</span>]}</span>:<span class="hljs-subst">#{source[<span class="hljs-number">1</span>]}</span>&quot;</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"<span class="hljs-subst">#{filename}</span>:<span class="hljs-subst">#{line}</span>:<span class="hljs-subst">#{column}</span>"</span>
<span class="hljs-string">&quot;<span class="hljs-subst">#{filename}</span>:<span class="hljs-subst">#{line}</span>:<span class="hljs-subst">#{column}</span>&quot;</span>
functionName = frame.getFunctionName()
isConstructor = frame.isConstructor()
@ -820,19 +820,19 @@ Modified to handle sourceMap</p>
typeName = frame.getTypeName()
<span class="hljs-keyword">if</span> functionName
tp = <span class="hljs-keyword">as</span> = <span class="hljs-string">''</span>
tp = <span class="hljs-keyword">as</span> = <span class="hljs-string">&#x27;&#x27;</span>
<span class="hljs-keyword">if</span> typeName <span class="hljs-keyword">and</span> functionName.indexOf typeName
tp = <span class="hljs-string">"<span class="hljs-subst">#{typeName}</span>."</span>
<span class="hljs-keyword">if</span> methodName <span class="hljs-keyword">and</span> functionName.indexOf(<span class="hljs-string">".<span class="hljs-subst">#{methodName}</span>"</span>) <span class="hljs-keyword">isnt</span> functionName.length - methodName.length - <span class="hljs-number">1</span>
<span class="hljs-keyword">as</span> = <span class="hljs-string">" [as <span class="hljs-subst">#{methodName}</span>]"</span>
tp = <span class="hljs-string">&quot;<span class="hljs-subst">#{typeName}</span>.&quot;</span>
<span class="hljs-keyword">if</span> methodName <span class="hljs-keyword">and</span> functionName.indexOf(<span class="hljs-string">&quot;.<span class="hljs-subst">#{methodName}</span>&quot;</span>) <span class="hljs-keyword">isnt</span> functionName.length - methodName.length - <span class="hljs-number">1</span>
<span class="hljs-keyword">as</span> = <span class="hljs-string">&quot; [as <span class="hljs-subst">#{methodName}</span>]&quot;</span>
<span class="hljs-string">"<span class="hljs-subst">#{tp}</span><span class="hljs-subst">#{functionName}</span><span class="hljs-subst">#{<span class="hljs-keyword">as</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)"</span>
<span class="hljs-string">&quot;<span class="hljs-subst">#{tp}</span><span class="hljs-subst">#{functionName}</span><span class="hljs-subst">#{<span class="hljs-keyword">as</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)&quot;</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"<span class="hljs-subst">#{typeName}</span>.<span class="hljs-subst">#{methodName <span class="hljs-keyword">or</span> <span class="hljs-string">'&lt;anonymous&gt;'</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)"</span>
<span class="hljs-string">&quot;<span class="hljs-subst">#{typeName}</span>.<span class="hljs-subst">#{methodName <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)&quot;</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> isConstructor
<span class="hljs-string">"new <span class="hljs-subst">#{functionName <span class="hljs-keyword">or</span> <span class="hljs-string">'&lt;anonymous&gt;'</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)"</span>
<span class="hljs-string">&quot;new <span class="hljs-subst">#{functionName <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span>}</span> (<span class="hljs-subst">#{fileLocation}</span>)&quot;</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> functionName
<span class="hljs-string">"<span class="hljs-subst">#{functionName}</span> (<span class="hljs-subst">#{fileLocation}</span>)"</span>
<span class="hljs-string">&quot;<span class="hljs-subst">#{functionName}</span> (<span class="hljs-subst">#{fileLocation}</span>)&quot;</span>
<span class="hljs-keyword">else</span>
fileLocation
<span class="hljs-function">
@ -844,17 +844,17 @@ Modified to handle sourceMap</p>
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-34">&#x00a7;</a>
</div>
<p>Skip files that we didnt compile, like Node system files that appear in
the stack trace, as they never have source maps.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span> <span class="hljs-keyword">unless</span> filename <span class="hljs-keyword">is</span> <span class="hljs-string">'&lt;anonymous&gt;'</span> <span class="hljs-keyword">or</span> filename.slice(filename.lastIndexOf(<span class="hljs-string">'.'</span>)) <span class="hljs-keyword">in</span> FILE_EXTENSIONS
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-literal">null</span> <span class="hljs-keyword">unless</span> filename <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span> <span class="hljs-keyword">or</span> filename.slice(filename.lastIndexOf(<span class="hljs-string">&#x27;.&#x27;</span>)) <span class="hljs-keyword">in</span> FILE_EXTENSIONS
<span class="hljs-keyword">if</span> filename <span class="hljs-keyword">isnt</span> <span class="hljs-string">'&lt;anonymous&gt;'</span> <span class="hljs-keyword">and</span> sourceMaps[filename]?
<span class="hljs-keyword">if</span> filename <span class="hljs-keyword">isnt</span> <span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span> <span class="hljs-keyword">and</span> sourceMaps[filename]?
<span class="hljs-keyword">return</span> sourceMaps[filename][sourceMaps[filename].length - <span class="hljs-number">1</span>]</pre></div></div>
</li>
@ -863,8 +863,8 @@ the stack trace, as they never have source maps.</p>
<li id="section-35">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-35">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-35">&#x00a7;</a>
</div>
<p>CoffeeScript compiled in a browser or via <code>CoffeeScript.compile</code> or <code>.run</code>
may get compiled with <code>options.filename</code> thats missing, which becomes
@ -874,7 +874,7 @@ filename of the script file. See if we have a source map cached under
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> sourceMaps[<span class="hljs-string">'&lt;anonymous&gt;'</span>]?</pre></div></div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> sourceMaps[<span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span>]?</pre></div></div>
</li>
@ -882,8 +882,8 @@ filename of the script file. See if we have a source map cached under
<li id="section-36">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-36">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-36">&#x00a7;</a>
</div>
<p>Work backwards from the most recent anonymous source maps, until we find
one that works. This isnt foolproof; there is a chance that multiple
@ -893,7 +893,7 @@ and its not foolproof either.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">for</span> map <span class="hljs-keyword">in</span> sourceMaps[<span class="hljs-string">'&lt;anonymous&gt;'</span>] <span class="hljs-keyword">by</span> <span class="hljs-number">-1</span>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">for</span> map <span class="hljs-keyword">in</span> sourceMaps[<span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span>] <span class="hljs-keyword">by</span> <span class="hljs-number">-1</span>
sourceLocation = map.sourceLocation [line - <span class="hljs-number">1</span>, column - <span class="hljs-number">1</span>]
<span class="hljs-keyword">return</span> map <span class="hljs-keyword">if</span> sourceLocation?[<span class="hljs-number">0</span>]? <span class="hljs-keyword">and</span> sourceLocation[<span class="hljs-number">1</span>]?</pre></div></div>
@ -903,8 +903,8 @@ and its not foolproof either.</p>
<li id="section-37">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-37">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-37">&#x00a7;</a>
</div>
<p>If all else fails, recompile this source to get a source map. We need the
previous section (for <code>&lt;anonymous&gt;</code>) despite this option, because after it
@ -930,8 +930,8 @@ time the source map we want is the last one.</p>
<li id="section-38">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-38">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-38">&#x00a7;</a>
</div>
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
NodeJS / V8 have no support for transforming positions in stack traces using
@ -940,30 +940,30 @@ positions.</p>
</div>
<div class="content"><div class='highlight'><pre>Error.prepareStackTrace = <span class="hljs-function"><span class="hljs-params">(err, stack)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">Error</span>.prepareStackTrace = <span class="hljs-function"><span class="hljs-params">(err, stack)</span> -&gt;</span>
<span class="hljs-function"> <span class="hljs-title">getSourceMapping</span> = <span class="hljs-params">(filename, line, column)</span> -&gt;</span>
sourceMap = getSourceMap filename, line, column
answer = sourceMap.sourceLocation [line - <span class="hljs-number">1</span>, column - <span class="hljs-number">1</span>] <span class="hljs-keyword">if</span> sourceMap?
<span class="hljs-keyword">if</span> answer? <span class="hljs-keyword">then</span> [answer[<span class="hljs-number">0</span>] + <span class="hljs-number">1</span>, answer[<span class="hljs-number">1</span>] + <span class="hljs-number">1</span>] <span class="hljs-keyword">else</span> <span class="hljs-literal">null</span>
frames = <span class="hljs-keyword">for</span> frame <span class="hljs-keyword">in</span> stack
<span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> frame.getFunction() <span class="hljs-keyword">is</span> exports.run
<span class="hljs-string">" at <span class="hljs-subst">#{formatSourcePosition frame, getSourceMapping}</span>"</span>
<span class="hljs-keyword">break</span> <span class="hljs-keyword">if</span> frame.getFunction() <span class="hljs-keyword">is</span> <span class="hljs-built_in">exports</span>.run
<span class="hljs-string">&quot; at <span class="hljs-subst">#{formatSourcePosition frame, getSourceMapping}</span>&quot;</span>
<span class="hljs-string">"<span class="hljs-subst">#{err.toString()}</span>\n<span class="hljs-subst">#{frames.join <span class="hljs-string">'\n'</span>}</span>\n"</span>
<span class="hljs-string">&quot;<span class="hljs-subst">#{err.toString()}</span>\n<span class="hljs-subst">#{frames.join <span class="hljs-string">&#x27;\n&#x27;</span>}</span>\n&quot;</span>
<span class="hljs-function">
<span class="hljs-title">checkShebangLine</span> = <span class="hljs-params">(file, input)</span> -&gt;</span>
firstLine = input.split(<span class="hljs-regexp">/$/m</span>)[<span class="hljs-number">0</span>]
rest = firstLine?.match(<span class="hljs-regexp">/^#!\s*([^\s]+\s*)(.*)/</span>)
args = rest?[<span class="hljs-number">2</span>]?.split(<span class="hljs-regexp">/\s/</span>).filter (s) -&gt; s <span class="hljs-keyword">isnt</span> <span class="hljs-string">''</span>
args = rest?[<span class="hljs-number">2</span>]?.split(<span class="hljs-regexp">/\s/</span>).filter (s) -&gt; s <span class="hljs-keyword">isnt</span> <span class="hljs-string">&#x27;&#x27;</span>
<span class="hljs-keyword">if</span> args?.length &gt; <span class="hljs-number">1</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
console.error <span class="hljs-string">&#x27;&#x27;&#x27;
The script to be run begins with a shebang line with more than one
argument. This script will fail on platforms such as Linux which only
allow a single argument.
'''</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"The shebang line was: '<span class="hljs-subst">#{firstLine}</span>' in file '<span class="hljs-subst">#{file}</span>'"</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"The arguments were: <span class="hljs-subst">#{JSON.stringify args}</span>"</span></pre></div></div>
&#x27;&#x27;&#x27;</span>
console.error <span class="hljs-string">&quot;The shebang line was: &#x27;<span class="hljs-subst">#{firstLine}</span>&#x27; in file &#x27;<span class="hljs-subst">#{file}</span>&#x27;&quot;</span>
console.error <span class="hljs-string">&quot;The arguments were: <span class="hljs-subst">#{<span class="hljs-built_in">JSON</span>.stringify args}</span>&quot;</span></pre></div></div>
</li>

View file

@ -112,8 +112,8 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
<p>The <code>coffee</code> utility. Handles command-line compilation of CoffeeScript
into various forms: saved into <code>.js</code> files or printed to stdout
@ -129,22 +129,22 @@ interactive REPL.</p>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>External dependencies.</p>
</div>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">'./optparse'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./'</span>
{spawn, exec} = <span class="hljs-built_in">require</span> <span class="hljs-string">'child_process'</span>
{EventEmitter} = <span class="hljs-built_in">require</span> <span class="hljs-string">'events'</span>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;fs&#x27;</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;path&#x27;</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./helpers&#x27;</span>
optparse = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./optparse&#x27;</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./&#x27;</span>
{spawn, exec} = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;child_process&#x27;</span>
{EventEmitter} = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;events&#x27;</span>
useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs-string">'\\'</span></pre></div></div>
useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;\\&#x27;</span></pre></div></div>
</li>
@ -152,8 +152,8 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>Allow CoffeeScript to emit Node.js events.</p>
@ -161,8 +161,8 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
<div class="content"><div class='highlight'><pre>helpers.extend CoffeeScript, <span class="hljs-keyword">new</span> EventEmitter
<span class="hljs-function">
<span class="hljs-title">printLine</span> = <span class="hljs-params">(line)</span> -&gt;</span> process.stdout.write line + <span class="hljs-string">'\n'</span>
<span class="hljs-function"><span class="hljs-title">printWarn</span> = <span class="hljs-params">(line)</span> -&gt;</span> process.stderr.write line + <span class="hljs-string">'\n'</span>
<span class="hljs-title">printLine</span> = <span class="hljs-params">(line)</span> -&gt;</span> process.stdout.write line + <span class="hljs-string">&#x27;\n&#x27;</span>
<span class="hljs-function"><span class="hljs-title">printWarn</span> = <span class="hljs-params">(line)</span> -&gt;</span> process.stderr.write line + <span class="hljs-string">&#x27;\n&#x27;</span>
<span class="hljs-function">
<span class="hljs-title">hidden</span> = <span class="hljs-params">(file)</span> -&gt;</span> <span class="hljs-regexp">/^\.|~$/</span>.test file</pre></div></div>
@ -172,18 +172,18 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>The help banner that is printed in conjunction with <code>-h</code>/<code>--help</code>.</p>
</div>
<div class="content"><div class='highlight'><pre>BANNER = <span class="hljs-string">'''
<div class="content"><div class='highlight'><pre>BANNER = <span class="hljs-string">&#x27;&#x27;&#x27;
Usage: coffee [options] path/to/script.coffee [args]
If called without options, `coffee` will run your script.
'''</span></pre></div></div>
&#x27;&#x27;&#x27;</span></pre></div></div>
</li>
@ -191,35 +191,35 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>The list of all the valid option flags that <code>coffee</code> knows how to handle.</p>
</div>
<div class="content"><div class='highlight'><pre>SWITCHES = [
[ <span class="hljs-string">'--ast'</span>, <span class="hljs-string">'generate an abstract syntax tree of nodes'</span>]
[<span class="hljs-string">'-b'</span>, <span class="hljs-string">'--bare'</span>, <span class="hljs-string">'compile without a top-level function wrapper'</span>]
[<span class="hljs-string">'-c'</span>, <span class="hljs-string">'--compile'</span>, <span class="hljs-string">'compile to JavaScript and save as .js files'</span>]
[<span class="hljs-string">'-e'</span>, <span class="hljs-string">'--eval'</span>, <span class="hljs-string">'pass a string from the command line as input'</span>]
[<span class="hljs-string">'-h'</span>, <span class="hljs-string">'--help'</span>, <span class="hljs-string">'display this help message'</span>]
[<span class="hljs-string">'-i'</span>, <span class="hljs-string">'--interactive'</span>, <span class="hljs-string">'run an interactive CoffeeScript REPL'</span>]
[<span class="hljs-string">'-j'</span>, <span class="hljs-string">'--join [FILE]'</span>, <span class="hljs-string">'concatenate the source CoffeeScript before compiling'</span>]
[<span class="hljs-string">'-l'</span>, <span class="hljs-string">'--literate'</span>, <span class="hljs-string">'treat stdio as literate style coffeescript'</span>]
[<span class="hljs-string">'-m'</span>, <span class="hljs-string">'--map'</span>, <span class="hljs-string">'generate source map and save as .js.map files'</span>]
[<span class="hljs-string">'-M'</span>, <span class="hljs-string">'--inline-map'</span>, <span class="hljs-string">'generate source map and include it directly in output'</span>]
[<span class="hljs-string">'-n'</span>, <span class="hljs-string">'--nodes'</span>, <span class="hljs-string">'print out the parse tree that the parser produces'</span>]
[ <span class="hljs-string">'--nodejs [ARGS]'</span>, <span class="hljs-string">'pass options directly to the "node" binary'</span>]
[ <span class="hljs-string">'--no-header'</span>, <span class="hljs-string">'suppress the "Generated by" header'</span>]
[<span class="hljs-string">'-o'</span>, <span class="hljs-string">'--output [PATH]'</span>, <span class="hljs-string">'set the output path or path/filename for compiled JavaScript'</span>]
[<span class="hljs-string">'-p'</span>, <span class="hljs-string">'--print'</span>, <span class="hljs-string">'print out the compiled JavaScript'</span>]
[<span class="hljs-string">'-r'</span>, <span class="hljs-string">'--require [MODULE*]'</span>, <span class="hljs-string">'require the given module before eval or REPL'</span>]
[<span class="hljs-string">'-s'</span>, <span class="hljs-string">'--stdio'</span>, <span class="hljs-string">'listen for and compile scripts over stdio'</span>]
[<span class="hljs-string">'-t'</span>, <span class="hljs-string">'--transpile'</span>, <span class="hljs-string">'pipe generated JavaScript through Babel'</span>]
[ <span class="hljs-string">'--tokens'</span>, <span class="hljs-string">'print out the tokens that the lexer/rewriter produce'</span>]
[<span class="hljs-string">'-v'</span>, <span class="hljs-string">'--version'</span>, <span class="hljs-string">'display the version number'</span>]
[<span class="hljs-string">'-w'</span>, <span class="hljs-string">'--watch'</span>, <span class="hljs-string">'watch scripts for changes and rerun commands'</span>]
[ <span class="hljs-string">&#x27;--ast&#x27;</span>, <span class="hljs-string">&#x27;generate an abstract syntax tree of nodes&#x27;</span>]
[<span class="hljs-string">&#x27;-b&#x27;</span>, <span class="hljs-string">&#x27;--bare&#x27;</span>, <span class="hljs-string">&#x27;compile without a top-level function wrapper&#x27;</span>]
[<span class="hljs-string">&#x27;-c&#x27;</span>, <span class="hljs-string">&#x27;--compile&#x27;</span>, <span class="hljs-string">&#x27;compile to JavaScript and save as .js files&#x27;</span>]
[<span class="hljs-string">&#x27;-e&#x27;</span>, <span class="hljs-string">&#x27;--eval&#x27;</span>, <span class="hljs-string">&#x27;pass a string from the command line as input&#x27;</span>]
[<span class="hljs-string">&#x27;-h&#x27;</span>, <span class="hljs-string">&#x27;--help&#x27;</span>, <span class="hljs-string">&#x27;display this help message&#x27;</span>]
[<span class="hljs-string">&#x27;-i&#x27;</span>, <span class="hljs-string">&#x27;--interactive&#x27;</span>, <span class="hljs-string">&#x27;run an interactive CoffeeScript REPL&#x27;</span>]
[<span class="hljs-string">&#x27;-j&#x27;</span>, <span class="hljs-string">&#x27;--join [FILE]&#x27;</span>, <span class="hljs-string">&#x27;concatenate the source CoffeeScript before compiling&#x27;</span>]
[<span class="hljs-string">&#x27;-l&#x27;</span>, <span class="hljs-string">&#x27;--literate&#x27;</span>, <span class="hljs-string">&#x27;treat stdio as literate style coffeescript&#x27;</span>]
[<span class="hljs-string">&#x27;-m&#x27;</span>, <span class="hljs-string">&#x27;--map&#x27;</span>, <span class="hljs-string">&#x27;generate source map and save as .js.map files&#x27;</span>]
[<span class="hljs-string">&#x27;-M&#x27;</span>, <span class="hljs-string">&#x27;--inline-map&#x27;</span>, <span class="hljs-string">&#x27;generate source map and include it directly in output&#x27;</span>]
[<span class="hljs-string">&#x27;-n&#x27;</span>, <span class="hljs-string">&#x27;--nodes&#x27;</span>, <span class="hljs-string">&#x27;print out the parse tree that the parser produces&#x27;</span>]
[ <span class="hljs-string">&#x27;--nodejs [ARGS]&#x27;</span>, <span class="hljs-string">&#x27;pass options directly to the &quot;node&quot; binary&#x27;</span>]
[ <span class="hljs-string">&#x27;--no-header&#x27;</span>, <span class="hljs-string">&#x27;suppress the &quot;Generated by&quot; header&#x27;</span>]
[<span class="hljs-string">&#x27;-o&#x27;</span>, <span class="hljs-string">&#x27;--output [PATH]&#x27;</span>, <span class="hljs-string">&#x27;set the output path or path/filename for compiled JavaScript&#x27;</span>]
[<span class="hljs-string">&#x27;-p&#x27;</span>, <span class="hljs-string">&#x27;--print&#x27;</span>, <span class="hljs-string">&#x27;print out the compiled JavaScript&#x27;</span>]
[<span class="hljs-string">&#x27;-r&#x27;</span>, <span class="hljs-string">&#x27;--require [MODULE*]&#x27;</span>, <span class="hljs-string">&#x27;require the given module before eval or REPL&#x27;</span>]
[<span class="hljs-string">&#x27;-s&#x27;</span>, <span class="hljs-string">&#x27;--stdio&#x27;</span>, <span class="hljs-string">&#x27;listen for and compile scripts over stdio&#x27;</span>]
[<span class="hljs-string">&#x27;-t&#x27;</span>, <span class="hljs-string">&#x27;--transpile&#x27;</span>, <span class="hljs-string">&#x27;pipe generated JavaScript through Babel&#x27;</span>]
[ <span class="hljs-string">&#x27;--tokens&#x27;</span>, <span class="hljs-string">&#x27;print out the tokens that the lexer/rewriter produce&#x27;</span>]
[<span class="hljs-string">&#x27;-v&#x27;</span>, <span class="hljs-string">&#x27;--version&#x27;</span>, <span class="hljs-string">&#x27;display the version number&#x27;</span>]
[<span class="hljs-string">&#x27;-w&#x27;</span>, <span class="hljs-string">&#x27;--watch&#x27;</span>, <span class="hljs-string">&#x27;watch scripts for changes and rerun commands&#x27;</span>]
]</pre></div></div>
</li>
@ -228,8 +228,8 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Top-level objects shared by all the functions.</p>
@ -242,7 +242,7 @@ notSources = {}
watchedDirs = {}
optionParser = <span class="hljs-literal">null</span>
exports.buildCSOptionParser = buildCSOptionParser = <span class="hljs-function">-&gt;</span>
<span class="hljs-built_in">exports</span>.buildCSOptionParser = buildCSOptionParser = <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">new</span> optparse.OptionParser SWITCHES, BANNER</pre></div></div>
</li>
@ -251,8 +251,8 @@ exports.buildCSOptionParser = buildCSOptionParser = <span class="hljs-function">
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Run <code>coffee</code> by parsing passed options and determining what action to take.
Many flags cause us to divert before compiling anything. Flags passed after
@ -260,22 +260,22 @@ Many flags cause us to divert before compiling anything. Flags passed after
</div>
<div class="content"><div class='highlight'><pre>exports.run = <span class="hljs-function">-&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.run = <span class="hljs-function">-&gt;</span>
optionParser = buildCSOptionParser()
<span class="hljs-keyword">try</span> parseOptions()
<span class="hljs-keyword">catch</span> err
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"option parsing error: <span class="hljs-subst">#{err.message}</span>"</span>
console.error <span class="hljs-string">&quot;option parsing error: <span class="hljs-subst">#{err.message}</span>&quot;</span>
process.exit <span class="hljs-number">1</span>
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">not</span> opts.doubleDashed) <span class="hljs-keyword">and</span> (opts.arguments[<span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'--'</span>)
printWarn <span class="hljs-string">'''
coffee was invoked with '--' as the second positional argument, which is
now deprecated. To pass '--' as an argument to a script to run, put an
additional '--' before the path to your script.
<span class="hljs-keyword">if</span> (<span class="hljs-keyword">not</span> opts.doubleDashed) <span class="hljs-keyword">and</span> (opts.arguments[<span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;--&#x27;</span>)
printWarn <span class="hljs-string">&#x27;&#x27;&#x27;
coffee was invoked with &#x27;--&#x27; as the second positional argument, which is
now deprecated. To pass &#x27;--&#x27; as an argument to a script to run, put an
additional &#x27;--&#x27; before the path to your script.
'--' will be removed from the argument list.
'''</span>
printWarn <span class="hljs-string">"The positional arguments were: <span class="hljs-subst">#{JSON.stringify opts.arguments}</span>"</span>
&#x27;--&#x27; will be removed from the argument list.
&#x27;&#x27;&#x27;</span>
printWarn <span class="hljs-string">&quot;The positional arguments were: <span class="hljs-subst">#{<span class="hljs-built_in">JSON</span>.stringify opts.arguments}</span>&quot;</span>
opts.arguments = [opts.arguments[<span class="hljs-number">0</span>]].concat opts.arguments[<span class="hljs-number">2.</span>.]</pre></div></div>
</li>
@ -284,8 +284,8 @@ Many flags cause us to divert before compiling anything. Flags passed after
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Make the REPL <em>CLI</em> use the global context so as to (a) be consistent with the
<code>node</code> REPL CLI and, therefore, (b) make packages that modify native prototypes
@ -300,18 +300,18 @@ Many flags cause us to divert before compiling anything. Flags passed after
<span class="hljs-keyword">return</span> forkNode() <span class="hljs-keyword">if</span> opts.nodejs
<span class="hljs-keyword">return</span> usage() <span class="hljs-keyword">if</span> opts.help
<span class="hljs-keyword">return</span> version() <span class="hljs-keyword">if</span> opts.version
<span class="hljs-keyword">return</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'./repl'</span>).start(replCliOpts) <span class="hljs-keyword">if</span> opts.interactive
<span class="hljs-keyword">return</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;./repl&#x27;</span>).start(replCliOpts) <span class="hljs-keyword">if</span> opts.interactive
<span class="hljs-keyword">return</span> compileStdio() <span class="hljs-keyword">if</span> opts.stdio
<span class="hljs-keyword">return</span> compileScript <span class="hljs-literal">null</span>, opts.arguments[<span class="hljs-number">0</span>] <span class="hljs-keyword">if</span> opts.eval
<span class="hljs-keyword">return</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">'./repl'</span>).start(replCliOpts) <span class="hljs-keyword">unless</span> opts.arguments.length
<span class="hljs-keyword">return</span> compileScript <span class="hljs-literal">null</span>, opts.arguments[<span class="hljs-number">0</span>] <span class="hljs-keyword">if</span> opts.<span class="hljs-built_in">eval</span>
<span class="hljs-keyword">return</span> <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;./repl&#x27;</span>).start(replCliOpts) <span class="hljs-keyword">unless</span> opts.arguments.length
literals = <span class="hljs-keyword">if</span> opts.run <span class="hljs-keyword">then</span> opts.arguments.splice <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> []
process.argv = process.argv[<span class="hljs-number">0.</span><span class="hljs-number">.1</span>].concat literals
process.argv[<span class="hljs-number">0</span>] = <span class="hljs-string">'coffee'</span>
process.argv[<span class="hljs-number">0</span>] = <span class="hljs-string">&#x27;coffee&#x27;</span>
<span class="hljs-keyword">if</span> opts.output
outputBasename = path.basename opts.output
<span class="hljs-keyword">if</span> <span class="hljs-string">'.'</span> <span class="hljs-keyword">in</span> outputBasename <span class="hljs-keyword">and</span>
outputBasename <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'.'</span>, <span class="hljs-string">'..'</span>] <span class="hljs-keyword">and</span>
<span class="hljs-keyword">if</span> <span class="hljs-string">&#x27;.&#x27;</span> <span class="hljs-keyword">in</span> outputBasename <span class="hljs-keyword">and</span>
outputBasename <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;.&#x27;</span>, <span class="hljs-string">&#x27;..&#x27;</span>] <span class="hljs-keyword">and</span>
<span class="hljs-keyword">not</span> helpers.ends(opts.output, path.sep)</pre></div></div>
</li>
@ -320,8 +320,8 @@ Many flags cause us to divert before compiling anything. Flags passed after
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p>An output filename was specified, e.g. <code>/dist/scripts.js</code>.</p>
@ -337,8 +337,8 @@ Many flags cause us to divert before compiling anything. Flags passed after
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>An output path was specified, e.g. <code>/dist</code>.</p>
@ -349,11 +349,11 @@ Many flags cause us to divert before compiling anything. Flags passed after
<span class="hljs-keyword">if</span> opts.join
opts.join = path.resolve opts.join
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
console.error <span class="hljs-string">&#x27;&#x27;&#x27;
The --join option is deprecated and will be removed in a future version.
If for some reason it's necessary to share local variables between files,
If for some reason it&#x27;s necessary to share local variables between files,
replace...
$ coffee --compile --join bundle.js -- a.coffee b.coffee c.coffee
@ -362,17 +362,17 @@ Many flags cause us to divert before compiling anything. Flags passed after
$ cat a.coffee b.coffee c.coffee | coffee --compile --stdio &gt; bundle.js
'''</span>
&#x27;&#x27;&#x27;</span>
<span class="hljs-keyword">for</span> source <span class="hljs-keyword">in</span> opts.arguments
source = path.resolve source
compilePath source, <span class="hljs-literal">yes</span>, source
<span class="hljs-function">
<span class="hljs-title">makePrelude</span> = <span class="hljs-params">(requires)</span> -&gt;</span>
requires.map (<span class="hljs-built_in">module</span>) -&gt;
[full, name, <span class="hljs-built_in">module</span>] = match <span class="hljs-keyword">if</span> match = <span class="hljs-built_in">module</span>.match(<span class="hljs-regexp">/^(.*)=(.*)$/</span>)
name <span class="hljs-keyword">or</span>= helpers.baseFileName <span class="hljs-built_in">module</span>, <span class="hljs-literal">yes</span>, useWinPathSep
<span class="hljs-string">"global['<span class="hljs-subst">#{name}</span>'] = require('<span class="hljs-subst">#{<span class="hljs-built_in">module</span>}</span>')"</span>
.join <span class="hljs-string">';'</span></pre></div></div>
requires.map (module) -&gt;
[full, name, module] = match <span class="hljs-keyword">if</span> match = module.match(<span class="hljs-regexp">/^(.*)=(.*)$/</span>)
name <span class="hljs-keyword">or</span>= helpers.baseFileName module, <span class="hljs-literal">yes</span>, useWinPathSep
<span class="hljs-string">&quot;global[&#x27;<span class="hljs-subst">#{name}</span>&#x27;] = require(&#x27;<span class="hljs-subst">#{module}</span>&#x27;)&quot;</span>
.join <span class="hljs-string">&#x27;;&#x27;</span></pre></div></div>
</li>
@ -380,8 +380,8 @@ Many flags cause us to divert before compiling anything. Flags passed after
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>Compile a path, which could be a script or a directory. If a directory
is passed, recursively compile all .coffee, .litcoffee, and .coffee.md
@ -396,12 +396,12 @@ extension source files in it and all subdirectories.</p>
<span class="hljs-keyword">try</span>
stats = fs.statSync source
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"File not found: <span class="hljs-subst">#{source}</span>"</span>
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;ENOENT&#x27;</span>
console.error <span class="hljs-string">&quot;File not found: <span class="hljs-subst">#{source}</span>&quot;</span>
process.exit <span class="hljs-number">1</span>
<span class="hljs-keyword">throw</span> err
<span class="hljs-keyword">if</span> stats.isDirectory()
<span class="hljs-keyword">if</span> path.basename(source) <span class="hljs-keyword">is</span> <span class="hljs-string">'node_modules'</span>
<span class="hljs-keyword">if</span> path.basename(source) <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;node_modules&#x27;</span>
notSources[source] = <span class="hljs-literal">yes</span>
<span class="hljs-keyword">return</span>
<span class="hljs-keyword">if</span> opts.run
@ -411,7 +411,7 @@ extension source files in it and all subdirectories.</p>
<span class="hljs-keyword">try</span>
files = fs.readdirSync source
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span> <span class="hljs-keyword">then</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> err
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;ENOENT&#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> err
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> files
compilePath (path.join source, file), <span class="hljs-literal">no</span>, base
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> topLevel <span class="hljs-keyword">or</span> helpers.isCoffee source
@ -422,19 +422,19 @@ extension source files in it and all subdirectories.</p>
<span class="hljs-keyword">try</span>
code = fs.readFileSync source
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span> <span class="hljs-keyword">then</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> err
<span class="hljs-keyword">if</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;ENOENT&#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-keyword">return</span> <span class="hljs-keyword">else</span> <span class="hljs-keyword">throw</span> err
compileScript source, code.toString(), base
<span class="hljs-keyword">else</span>
notSources[source] = <span class="hljs-literal">yes</span>
<span class="hljs-function">
<span class="hljs-title">findDirectoryIndex</span> = <span class="hljs-params">(source)</span> -&gt;</span>
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> CoffeeScript.FILE_EXTENSIONS
index = path.join source, <span class="hljs-string">"index<span class="hljs-subst">#{ext}</span>"</span>
index = path.join source, <span class="hljs-string">&quot;index<span class="hljs-subst">#{ext}</span>&quot;</span>
<span class="hljs-keyword">try</span>
<span class="hljs-keyword">return</span> index <span class="hljs-keyword">if</span> (fs.statSync index).isFile()
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">"Missing index.coffee or index.litcoffee in <span class="hljs-subst">#{source}</span>"</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;ENOENT&#x27;</span>
console.error <span class="hljs-string">&quot;Missing index.coffee or index.litcoffee in <span class="hljs-subst">#{source}</span>&quot;</span>
process.exit <span class="hljs-number">1</span></pre></div></div>
</li>
@ -443,8 +443,8 @@ extension source files in it and all subdirectories.</p>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>Compile a single source script, containing the given code, according to the
requested options. If evaluating the script directly, set <code>__filename</code>,
@ -456,17 +456,17 @@ requested options. If evaluating the script directly, set <code>__filename</code
options = compileOptions file, base
<span class="hljs-keyword">try</span>
task = {file, input, options}
CoffeeScript.emit <span class="hljs-string">'compile'</span>, task
CoffeeScript.emit <span class="hljs-string">&#x27;compile&#x27;</span>, task
<span class="hljs-keyword">if</span> opts.tokens
printTokens CoffeeScript.tokens task.input, task.options
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.nodes
printLine CoffeeScript.nodes(task.input, task.options).toString().trim()
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.ast
compiled = CoffeeScript.compile task.input, task.options
printLine JSON.stringify(compiled, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>)
printLine <span class="hljs-built_in">JSON</span>.stringify(compiled, <span class="hljs-literal">null</span>, <span class="hljs-number">2</span>)
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.run
CoffeeScript.register()
CoffeeScript.eval opts.prelude, task.options <span class="hljs-keyword">if</span> opts.prelude
CoffeeScript.<span class="hljs-built_in">eval</span> opts.prelude, task.options <span class="hljs-keyword">if</span> opts.prelude
CoffeeScript.run task.input, task.options
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.join <span class="hljs-keyword">and</span> task.file <span class="hljs-keyword">isnt</span> opts.join
task.input = helpers.invertLiterate task.input <span class="hljs-keyword">if</span> helpers.isLiterate file
@ -479,7 +479,7 @@ requested options. If evaluating the script directly, set <code>__filename</code
task.output = compiled.js
task.sourceMap = compiled.v3SourceMap
CoffeeScript.emit <span class="hljs-string">'success'</span>, task
CoffeeScript.emit <span class="hljs-string">&#x27;success&#x27;</span>, task
<span class="hljs-keyword">if</span> opts.<span class="hljs-built_in">print</span>
printLine task.output.trim()
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.compile <span class="hljs-keyword">or</span> opts.map
@ -489,11 +489,11 @@ requested options. If evaluating the script directly, set <code>__filename</code
options.jsPath
writeJs base, task.file, task.output, saveTo, task.sourceMap
<span class="hljs-keyword">catch</span> err
CoffeeScript.emit <span class="hljs-string">'failure'</span>, err, task
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> CoffeeScript.listeners(<span class="hljs-string">'failure'</span>).length
message = err?.stack <span class="hljs-keyword">or</span> <span class="hljs-string">"<span class="hljs-subst">#{err}</span>"</span>
CoffeeScript.emit <span class="hljs-string">&#x27;failure&#x27;</span>, err, task
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> CoffeeScript.listeners(<span class="hljs-string">&#x27;failure&#x27;</span>).length
message = err?.stack <span class="hljs-keyword">or</span> <span class="hljs-string">&quot;<span class="hljs-subst">#{err}</span>&quot;</span>
<span class="hljs-keyword">if</span> opts.watch
printLine message + <span class="hljs-string">'\x07'</span>
printLine message + <span class="hljs-string">&#x27;\x07&#x27;</span>
<span class="hljs-keyword">else</span>
printWarn message
process.exit <span class="hljs-number">1</span></pre></div></div>
@ -504,8 +504,8 @@ requested options. If evaluating the script directly, set <code>__filename</code
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-13">&#x00a7;</a>
</div>
<p>Attach the appropriate listeners to compile scripts incoming over <strong>stdin</strong>,
and write them back to <strong>stdout</strong>.</p>
@ -514,13 +514,13 @@ and write them back to <strong>stdout</strong>.</p>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">compileStdio</span> = -&gt;</span>
<span class="hljs-keyword">if</span> opts.map
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'--stdio and --map cannot be used together'</span>
console.error <span class="hljs-string">&#x27;--stdio and --map cannot be used together&#x27;</span>
process.exit <span class="hljs-number">1</span>
buffers = []
stdin = process.openStdin()
stdin.<span class="hljs-literal">on</span> <span class="hljs-string">'data'</span>, <span class="hljs-function"><span class="hljs-params">(buffer)</span> -&gt;</span>
stdin.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;data&#x27;</span>, <span class="hljs-function"><span class="hljs-params">(buffer)</span> -&gt;</span>
buffers.push buffer <span class="hljs-keyword">if</span> buffer
stdin.<span class="hljs-literal">on</span> <span class="hljs-string">'end'</span>, <span class="hljs-function">-&gt;</span>
stdin.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;end&#x27;</span>, <span class="hljs-function">-&gt;</span>
compileScript <span class="hljs-literal">null</span>, Buffer.concat(buffers).toString()</pre></div></div>
</li>
@ -529,8 +529,8 @@ and write them back to <strong>stdout</strong>.</p>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-14">&#x00a7;</a>
</div>
<p>If all of the source files are done being read, concatenate and compile
them together.</p>
@ -541,9 +541,9 @@ them together.</p>
<span class="hljs-function"><span class="hljs-title">compileJoin</span> = -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> opts.join
<span class="hljs-keyword">unless</span> sourceCode.some(<span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span> code <span class="hljs-keyword">is</span> <span class="hljs-literal">null</span>)
clearTimeout joinTimeout
<span class="hljs-built_in">clearTimeout</span> joinTimeout
joinTimeout = wait <span class="hljs-number">100</span>, <span class="hljs-function">-&gt;</span>
compileScript opts.join, sourceCode.join(<span class="hljs-string">'\n'</span>), opts.join</pre></div></div>
compileScript opts.join, sourceCode.join(<span class="hljs-string">&#x27;\n&#x27;</span>), opts.join</pre></div></div>
</li>
@ -551,8 +551,8 @@ them together.</p>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-15">&#x00a7;</a>
</div>
<p>Watch a source CoffeeScript file using <code>fs.watch</code>, recompiling it every
time the file is updated. May be used in combination with other options,
@ -566,7 +566,7 @@ such as <code>--print</code>.</p>
compileTimeout = <span class="hljs-literal">null</span>
<span class="hljs-function">
<span class="hljs-title">watchErr</span> = <span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;ENOENT&#x27;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> source <span class="hljs-keyword">in</span> sources
<span class="hljs-keyword">try</span>
rewatch()
@ -576,7 +576,7 @@ such as <code>--print</code>.</p>
compileJoin()
<span class="hljs-function">
<span class="hljs-title">compile</span> = -&gt;</span>
clearTimeout compileTimeout
<span class="hljs-built_in">clearTimeout</span> compileTimeout
compileTimeout = wait <span class="hljs-number">25</span>, <span class="hljs-function">-&gt;</span>
fs.stat source, <span class="hljs-function"><span class="hljs-params">(err, stats)</span> -&gt;</span>
<span class="hljs-keyword">return</span> watchErr err <span class="hljs-keyword">if</span> err
@ -591,9 +591,9 @@ such as <code>--print</code>.</p>
<span class="hljs-function">
<span class="hljs-title">startWatcher</span> = -&gt;</span>
watcher = fs.watch source
.<span class="hljs-literal">on</span> <span class="hljs-string">'change'</span>, compile
.<span class="hljs-literal">on</span> <span class="hljs-string">'error'</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'EPERM'</span>
.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;change&#x27;</span>, compile
.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;error&#x27;</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;EPERM&#x27;</span>
removeSource source, base
<span class="hljs-function">
<span class="hljs-title">rewatch</span> = -&gt;</span>
@ -611,8 +611,8 @@ such as <code>--print</code>.</p>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-16">&#x00a7;</a>
</div>
<p>Watch a directory of files for new additions.</p>
@ -624,16 +624,16 @@ such as <code>--print</code>.</p>
<span class="hljs-function">
<span class="hljs-title">startWatcher</span> = -&gt;</span>
watcher = fs.watch source
.<span class="hljs-literal">on</span> <span class="hljs-string">'error'</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'EPERM'</span>
.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;error&#x27;</span>, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;EPERM&#x27;</span>
stopWatcher()
.<span class="hljs-literal">on</span> <span class="hljs-string">'change'</span>, <span class="hljs-function">-&gt;</span>
clearTimeout readdirTimeout
.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;change&#x27;</span>, <span class="hljs-function">-&gt;</span>
<span class="hljs-built_in">clearTimeout</span> readdirTimeout
readdirTimeout = wait <span class="hljs-number">25</span>, <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">try</span>
files = fs.readdirSync source
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;ENOENT&#x27;</span>
<span class="hljs-keyword">return</span> stopWatcher()
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> files
compilePath (path.join source, file), <span class="hljs-literal">no</span>, base
@ -646,7 +646,7 @@ such as <code>--print</code>.</p>
<span class="hljs-keyword">try</span>
startWatcher()
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">'ENOENT'</span>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;ENOENT&#x27;</span>
<span class="hljs-function">
<span class="hljs-title">removeSourceDir</span> = <span class="hljs-params">(source, base)</span> -&gt;</span>
<span class="hljs-keyword">delete</span> watchedDirs[source]
@ -662,8 +662,8 @@ such as <code>--print</code>.</p>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-17">&#x00a7;</a>
</div>
<p>Remove a file from our source list, and source code cache. Optionally remove
the compiled JS version as well.</p>
@ -676,14 +676,14 @@ the compiled JS version as well.</p>
sourceCode.splice index, <span class="hljs-number">1</span>
<span class="hljs-keyword">unless</span> opts.join
silentUnlink outputPath source, base
silentUnlink outputPath source, base, <span class="hljs-string">'.js.map'</span>
timeLog <span class="hljs-string">"removed <span class="hljs-subst">#{source}</span>"</span>
silentUnlink outputPath source, base, <span class="hljs-string">&#x27;.js.map&#x27;</span>
timeLog <span class="hljs-string">&quot;removed <span class="hljs-subst">#{source}</span>&quot;</span>
<span class="hljs-function">
<span class="hljs-title">silentUnlink</span> = <span class="hljs-params">(path)</span> -&gt;</span>
<span class="hljs-keyword">try</span>
fs.unlinkSync path
<span class="hljs-keyword">catch</span> err
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">in</span> [<span class="hljs-string">'ENOENT'</span>, <span class="hljs-string">'EPERM'</span>]</pre></div></div>
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">unless</span> err.code <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;ENOENT&#x27;</span>, <span class="hljs-string">&#x27;EPERM&#x27;</span>]</pre></div></div>
</li>
@ -691,14 +691,14 @@ the compiled JS version as well.</p>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-18">&#x00a7;</a>
</div>
<p>Get the corresponding output JavaScript path for a source file.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">outputPath</span> = <span class="hljs-params">(source, base, extension=<span class="hljs-string">".js"</span>)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">outputPath</span> = <span class="hljs-params">(source, base, extension=<span class="hljs-string">&quot;.js&quot;</span>)</span> -&gt;</span>
basename = helpers.baseFileName source, <span class="hljs-literal">yes</span>, useWinPathSep
srcDir = path.dirname source
dir = <span class="hljs-keyword">unless</span> opts.outputPath
@ -715,8 +715,8 @@ the compiled JS version as well.</p>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-19">&#x00a7;</a>
</div>
<p>Recursively mkdir, like <code>mkdir -p</code>.</p>
@ -741,8 +741,8 @@ the compiled JS version as well.</p>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-20">&#x00a7;</a>
</div>
<p>Write out a JavaScript source file with the compiled code. By default, files
are written out in <code>cwd</code> as <code>.js</code> files with the same name, but the output
@ -753,22 +753,22 @@ same directory as the <code>.js</code> file.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">writeJs</span> = <span class="hljs-params">(base, sourcePath, js, jsPath, generatedSourceMap = <span class="hljs-literal">null</span>)</span> -&gt;</span>
sourceMapPath = <span class="hljs-string">"<span class="hljs-subst">#{jsPath}</span>.map"</span>
sourceMapPath = <span class="hljs-string">&quot;<span class="hljs-subst">#{jsPath}</span>.map&quot;</span>
jsDir = path.dirname jsPath
<span class="hljs-function"> <span class="hljs-title">compile</span> = -&gt;</span>
<span class="hljs-keyword">if</span> opts.compile
js = <span class="hljs-string">' '</span> <span class="hljs-keyword">if</span> js.length &lt;= <span class="hljs-number">0</span>
<span class="hljs-keyword">if</span> generatedSourceMap <span class="hljs-keyword">then</span> js = <span class="hljs-string">"<span class="hljs-subst">#{js}</span>\n//# sourceMappingURL=<span class="hljs-subst">#{helpers.baseFileName sourceMapPath, <span class="hljs-literal">no</span>, useWinPathSep}</span>\n"</span>
js = <span class="hljs-string">&#x27; &#x27;</span> <span class="hljs-keyword">if</span> js.length &lt;= <span class="hljs-number">0</span>
<span class="hljs-keyword">if</span> generatedSourceMap <span class="hljs-keyword">then</span> js = <span class="hljs-string">&quot;<span class="hljs-subst">#{js}</span>\n//# sourceMappingURL=<span class="hljs-subst">#{helpers.baseFileName sourceMapPath, <span class="hljs-literal">no</span>, useWinPathSep}</span>\n&quot;</span>
fs.writeFile jsPath, js, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">if</span> err
printLine err.message
process.exit <span class="hljs-number">1</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> opts.compile <span class="hljs-keyword">and</span> opts.watch
timeLog <span class="hljs-string">"compiled <span class="hljs-subst">#{sourcePath}</span>"</span>
timeLog <span class="hljs-string">&quot;compiled <span class="hljs-subst">#{sourcePath}</span>&quot;</span>
<span class="hljs-keyword">if</span> generatedSourceMap
fs.writeFile sourceMapPath, generatedSourceMap, <span class="hljs-function"><span class="hljs-params">(err)</span> -&gt;</span>
<span class="hljs-keyword">if</span> err
printLine <span class="hljs-string">"Could not write source map: <span class="hljs-subst">#{err.message}</span>"</span>
printLine <span class="hljs-string">&quot;Could not write source map: <span class="hljs-subst">#{err.message}</span>&quot;</span>
process.exit <span class="hljs-number">1</span>
fs.exists jsDir, <span class="hljs-function"><span class="hljs-params">(itExists)</span> -&gt;</span>
<span class="hljs-keyword">if</span> itExists <span class="hljs-keyword">then</span> compile() <span class="hljs-keyword">else</span> mkdirp jsDir, compile</pre></div></div>
@ -779,14 +779,14 @@ same directory as the <code>.js</code> file.</p>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-21">&#x00a7;</a>
</div>
<p>Convenience for cleaner setTimeouts.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">wait</span> = <span class="hljs-params">(milliseconds, func)</span> -&gt;</span> setTimeout func, milliseconds</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">wait</span> = <span class="hljs-params">(milliseconds, func)</span> -&gt;</span> <span class="hljs-built_in">setTimeout</span> func, milliseconds</pre></div></div>
</li>
@ -794,15 +794,15 @@ same directory as the <code>.js</code> file.</p>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-22">&#x00a7;</a>
</div>
<p>When watching scripts, its useful to log changes with the timestamp.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">timeLog</span> = <span class="hljs-params">(message)</span> -&gt;</span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">"<span class="hljs-subst">#{(<span class="hljs-keyword">new</span> Date).toLocaleTimeString()}</span> - <span class="hljs-subst">#{message}</span>"</span></pre></div></div>
console.log <span class="hljs-string">&quot;<span class="hljs-subst">#{(<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>).toLocaleTimeString()}</span> - <span class="hljs-subst">#{message}</span>&quot;</span></pre></div></div>
</li>
@ -810,8 +810,8 @@ same directory as the <code>.js</code> file.</p>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-23">&#x00a7;</a>
</div>
<p>Pretty-print a stream of tokens, sans location data.</p>
@ -820,9 +820,9 @@ same directory as the <code>.js</code> file.</p>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">printTokens</span> = <span class="hljs-params">(tokens)</span> -&gt;</span>
strings = <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens
tag = token[<span class="hljs-number">0</span>]
value = token[<span class="hljs-number">1</span>].toString().replace(<span class="hljs-regexp">/\n/</span>, <span class="hljs-string">'\\n'</span>)
<span class="hljs-string">"[<span class="hljs-subst">#{tag}</span> <span class="hljs-subst">#{value}</span>]"</span>
printLine strings.join(<span class="hljs-string">' '</span>)</pre></div></div>
value = token[<span class="hljs-number">1</span>].toString().replace(<span class="hljs-regexp">/\n/</span>, <span class="hljs-string">&#x27;\\n&#x27;</span>)
<span class="hljs-string">&quot;[<span class="hljs-subst">#{tag}</span> <span class="hljs-subst">#{value}</span>]&quot;</span>
printLine strings.join(<span class="hljs-string">&#x27; &#x27;</span>)</pre></div></div>
</li>
@ -830,8 +830,8 @@ same directory as the <code>.js</code> file.</p>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-24">&#x00a7;</a>
</div>
<p>Use the <a href="optparse.html">OptionParser module</a> to extract all options from
<code>process.argv</code> that are specified in <code>SWITCHES</code>.</p>
@ -842,7 +842,7 @@ same directory as the <code>.js</code> file.</p>
o = opts = optionParser.parse process.argv[<span class="hljs-number">2.</span>.]
o.compile <span class="hljs-keyword">or</span>= !!o.output
o.run = <span class="hljs-keyword">not</span> (o.compile <span class="hljs-keyword">or</span> o.<span class="hljs-built_in">print</span> <span class="hljs-keyword">or</span> o.map)
o.<span class="hljs-built_in">print</span> = !! (o.<span class="hljs-built_in">print</span> <span class="hljs-keyword">or</span> (o.eval <span class="hljs-keyword">or</span> o.stdio <span class="hljs-keyword">and</span> o.compile))</pre></div></div>
o.<span class="hljs-built_in">print</span> = !! (o.<span class="hljs-built_in">print</span> <span class="hljs-keyword">or</span> (o.<span class="hljs-built_in">eval</span> <span class="hljs-keyword">or</span> o.stdio <span class="hljs-keyword">and</span> o.compile))</pre></div></div>
</li>
@ -850,8 +850,8 @@ same directory as the <code>.js</code> file.</p>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-25">&#x00a7;</a>
</div>
<p>The compile-time options to pass to the CoffeeScript compiler.</p>
@ -866,8 +866,8 @@ same directory as the <code>.js</code> file.</p>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-26">&#x00a7;</a>
</div>
<p>The user has requested that the CoffeeScript compiler also transpile
via Babel. We dont include Babel as a dependency because we want to
@ -879,10 +879,10 @@ browsers) or use a proper build chain like Gulp or Webpack.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">try</span>
<span class="hljs-built_in">require</span> <span class="hljs-string">'@babel/core'</span>
<span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;@babel/core&#x27;</span>
<span class="hljs-keyword">catch</span>
<span class="hljs-keyword">try</span>
<span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
<span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;babel-core&#x27;</span>
<span class="hljs-keyword">catch</span></pre></div></div>
</li>
@ -891,31 +891,31 @@ browsers) or use a proper build chain like Gulp or Webpack.</p>
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-27">&#x00a7;</a>
</div>
<p>Give appropriate instructions depending on whether <code>coffee</code> was run
locally or globally.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.resolve(<span class="hljs-string">'.'</span>).indexOf(process.cwd()) <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.resolve(<span class="hljs-string">&#x27;.&#x27;</span>).indexOf(process.cwd()) <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
console.error <span class="hljs-string">&#x27;&#x27;&#x27;
To use --transpile, you must have @babel/core installed:
npm install --save-dev @babel/core
And you must save options to configure Babel in one of the places it looks to find its options.
See https://coffeescript.org/#transpilation
'''</span>
&#x27;&#x27;&#x27;</span>
<span class="hljs-keyword">else</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
console.error <span class="hljs-string">&#x27;&#x27;&#x27;
To use --transpile with globally-installed CoffeeScript, you must have @babel/core installed globally:
npm install --global @babel/core
And you must save options to configure Babel in one of the places it looks to find its options, relative to the file being compiled or to the current folder.
See https://coffeescript.org/#transpilation
'''</span>
&#x27;&#x27;&#x27;</span>
process.exit <span class="hljs-number">1</span>
opts.transpile = {} <span class="hljs-keyword">unless</span> <span class="hljs-keyword">typeof</span> opts.transpile <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span></pre></div></div>
opts.transpile = {} <span class="hljs-keyword">unless</span> <span class="hljs-keyword">typeof</span> opts.transpile <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;object&#x27;</span></pre></div></div>
</li>
@ -923,8 +923,8 @@ locally or globally.</p>
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-28">&#x00a7;</a>
</div>
<p>Pass a reference to Babel into the compiler, so that the transpile option
is available for the CLI. We need to do this so that tools like Webpack
@ -941,8 +941,8 @@ require Babel.</p>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-29">&#x00a7;</a>
</div>
<p>Babel searches for its options (a <code>.babelrc</code> file, a <code>.babelrc.js</code> file,
a <code>package.json</code> file with a <code>babel</code> key, etc.) relative to the path
@ -952,7 +952,7 @@ along.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> opts.transpile.filename
opts.transpile.filename = filename <span class="hljs-keyword">or</span> path.resolve(base <span class="hljs-keyword">or</span> process.cwd(), <span class="hljs-string">'&lt;anonymous&gt;'</span>)
opts.transpile.filename = filename <span class="hljs-keyword">or</span> path.resolve(base <span class="hljs-keyword">or</span> process.cwd(), <span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span>)
<span class="hljs-keyword">else</span>
opts.transpile = <span class="hljs-literal">no</span>
@ -960,10 +960,10 @@ along.</p>
filename: filename
literate: opts.literate <span class="hljs-keyword">or</span> helpers.isLiterate(filename)
bare: opts.bare
header: opts.compile <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> opts[<span class="hljs-string">'no-header'</span>]
header: opts.compile <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> opts[<span class="hljs-string">&#x27;no-header&#x27;</span>]
transpile: opts.transpile
sourceMap: opts.map
inlineMap: opts[<span class="hljs-string">'inline-map'</span>]
inlineMap: opts[<span class="hljs-string">&#x27;inline-map&#x27;</span>]
ast: opts.ast
<span class="hljs-keyword">if</span> filename
@ -979,9 +979,9 @@ along.</p>
}
<span class="hljs-keyword">else</span>
answer = helpers.merge answer,
sourceRoot: <span class="hljs-string">""</span>
sourceRoot: <span class="hljs-string">&quot;&quot;</span>
sourceFiles: [helpers.baseFileName filename, <span class="hljs-literal">no</span>, useWinPathSep]
generatedFile: helpers.baseFileName(filename, <span class="hljs-literal">yes</span>, useWinPathSep) + <span class="hljs-string">".js"</span>
generatedFile: helpers.baseFileName(filename, <span class="hljs-literal">yes</span>, useWinPathSep) + <span class="hljs-string">&quot;.js&quot;</span>
answer</pre></div></div>
</li>
@ -990,8 +990,8 @@ along.</p>
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-30">&#x00a7;</a>
</div>
<p>Start up a new Node.js instance with the arguments in <code>--nodejs</code> passed to
the <code>node</code> binary, preserving the other options.</p>
@ -1001,15 +1001,15 @@ the <code>node</code> binary, preserving the other options.</p>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">forkNode</span> = -&gt;</span>
nodeArgs = opts.nodejs.split <span class="hljs-regexp">/\s+/</span>
args = process.argv[<span class="hljs-number">1.</span>.]
args.splice args.indexOf(<span class="hljs-string">'--nodejs'</span>), <span class="hljs-number">2</span>
args.splice args.indexOf(<span class="hljs-string">&#x27;--nodejs&#x27;</span>), <span class="hljs-number">2</span>
p = spawn process.execPath, nodeArgs.concat(args),
cwd: process.cwd()
env: process.env
stdio: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
<span class="hljs-keyword">for</span> signal <span class="hljs-keyword">in</span> [<span class="hljs-string">'SIGINT'</span>, <span class="hljs-string">'SIGTERM'</span>]
<span class="hljs-keyword">for</span> signal <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;SIGINT&#x27;</span>, <span class="hljs-string">&#x27;SIGTERM&#x27;</span>]
process.<span class="hljs-literal">on</span> signal, <span class="hljs-keyword">do</span> (signal) -&gt;
-&gt; p.kill signal
p.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span> process.exit code</pre></div></div>
p.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;exit&#x27;</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span> process.exit code</pre></div></div>
</li>
@ -1017,8 +1017,8 @@ the <code>node</code> binary, preserving the other options.</p>
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-31">&#x00a7;</a>
</div>
<p>Print the <code>--help</code> usage message and exit. Deprecated switches are not
shown.</p>
@ -1034,15 +1034,15 @@ shown.</p>
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-32">&#x00a7;</a>
</div>
<p>Print the <code>--version</code> message and exit.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">version</span> = -&gt;</span>
printLine <span class="hljs-string">"CoffeeScript version <span class="hljs-subst">#{CoffeeScript.VERSION}</span>"</span></pre></div></div>
printLine <span class="hljs-string">&quot;CoffeeScript version <span class="hljs-subst">#{CoffeeScript.VERSION}</span>&quot;</span></pre></div></div>
</li>

View file

@ -213,7 +213,7 @@ ul.sections > li > div {
/*---------------------- Low resolutions (> 320px) ---------------------*/
@media only screen and (min-width: 320px) {
.pilwrap { display: none; }
.sswrap { display: none; }
ul.sections > li > div {
display: block;
@ -330,12 +330,12 @@ ul.sections > li > div {
box-shadow: none;
}
.pilwrap {
.sswrap {
position: relative;
display: inline;
}
.pilcrow {
.ss {
font: 12px Arial;
text-decoration: none;
color: #454545;
@ -345,14 +345,14 @@ ul.sections > li > div {
opacity: 0;
-webkit-transition: opacity 0.2s linear;
}
.for-h1 .pilcrow {
.for-h1 .ss {
top: 47px;
}
.for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow {
.for-h2 .ss, .for-h3 .ss, .for-h4 .ss {
top: 35px;
}
ul.sections > li > div.annotation:hover .pilcrow {
ul.sections > li > div.annotation:hover .ss {
opacity: 1;
}
}

File diff suppressed because it is too large Load diff

View file

@ -112,8 +112,8 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
<p>This file contains the common helper functions that wed like to share among
the <strong>Lexer</strong>, <strong>Rewriter</strong>, and the <strong>Nodes</strong>. Merge objects, flatten
@ -127,14 +127,14 @@ arrays, count characters, that sort of thing.</p>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>Peek at the beginning of a given string to see if it matches a sequence.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.starts = <span class="hljs-function"><span class="hljs-params">(string, literal, start)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.starts = <span class="hljs-function"><span class="hljs-params">(string, literal, start)</span> -&gt;</span>
literal <span class="hljs-keyword">is</span> string.substr start, literal.length</pre></div></div>
</li>
@ -143,14 +143,14 @@ arrays, count characters, that sort of thing.</p>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>Peek at the end of a given string to see if it matches a sequence.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.ends = <span class="hljs-function"><span class="hljs-params">(string, literal, back)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.ends = <span class="hljs-function"><span class="hljs-params">(string, literal, back)</span> -&gt;</span>
len = literal.length
literal <span class="hljs-keyword">is</span> string.substr string.length - len - (back <span class="hljs-keyword">or</span> <span class="hljs-number">0</span>), len</pre></div></div>
@ -160,14 +160,14 @@ arrays, count characters, that sort of thing.</p>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Repeat a string <code>n</code> times.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.repeat = repeat = <span class="hljs-function"><span class="hljs-params">(str, n)</span> -&gt;</span></pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.repeat = repeat = <span class="hljs-function"><span class="hljs-params">(str, n)</span> -&gt;</span></pre></div></div>
</li>
@ -175,14 +175,14 @@ arrays, count characters, that sort of thing.</p>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>Use clever algorithm to have O(log(n)) string concatenation operations.</p>
</div>
<div class="content"><div class='highlight'><pre> res = <span class="hljs-string">''</span>
<div class="content"><div class='highlight'><pre> res = <span class="hljs-string">&#x27;&#x27;</span>
<span class="hljs-keyword">while</span> n &gt; <span class="hljs-number">0</span>
res += str <span class="hljs-keyword">if</span> n &amp; <span class="hljs-number">1</span>
n &gt;&gt;&gt;= <span class="hljs-number">1</span>
@ -195,14 +195,14 @@ arrays, count characters, that sort of thing.</p>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Trim out all falsy values from an array.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.compact = <span class="hljs-function"><span class="hljs-params">(array)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.compact = <span class="hljs-function"><span class="hljs-params">(array)</span> -&gt;</span>
item <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> array <span class="hljs-keyword">when</span> item</pre></div></div>
</li>
@ -211,14 +211,14 @@ arrays, count characters, that sort of thing.</p>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Count the number of occurrences of a string in a string.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.count = <span class="hljs-function"><span class="hljs-params">(string, substr)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.count = <span class="hljs-function"><span class="hljs-params">(string, substr)</span> -&gt;</span>
num = pos = <span class="hljs-number">0</span>
<span class="hljs-keyword">return</span> <span class="hljs-number">1</span>/<span class="hljs-number">0</span> <span class="hljs-keyword">unless</span> substr.length
num++ <span class="hljs-keyword">while</span> pos = <span class="hljs-number">1</span> + string.indexOf substr, pos
@ -230,8 +230,8 @@ arrays, count characters, that sort of thing.</p>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Merge objects, returning a fresh copy with attributes from both sides.
Used every time <code>Base#compile</code> is called, to allow properties in the
@ -239,7 +239,7 @@ options hash to propagate down the tree without polluting other branches.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.merge = <span class="hljs-function"><span class="hljs-params">(options, overrides)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.merge = <span class="hljs-function"><span class="hljs-params">(options, overrides)</span> -&gt;</span>
extend (extend {}, options), overrides</pre></div></div>
</li>
@ -248,14 +248,14 @@ options hash to propagate down the tree without polluting other branches.</p>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p>Extend a source object with the properties of another object (shallow copy).</p>
</div>
<div class="content"><div class='highlight'><pre>extend = exports.extend = <span class="hljs-function"><span class="hljs-params">(object, properties)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre>extend = <span class="hljs-built_in">exports</span>.extend = <span class="hljs-function"><span class="hljs-params">(object, properties)</span> -&gt;</span>
<span class="hljs-keyword">for</span> key, val <span class="hljs-keyword">of</span> properties
object[key] = val
object</pre></div></div>
@ -266,18 +266,18 @@ options hash to propagate down the tree without polluting other branches.</p>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>Return a flattened version of an array.
Handy for getting a list of <code>children</code> from the nodes.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.flatten = flatten = <span class="hljs-function"><span class="hljs-params">(array)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.flatten = flatten = <span class="hljs-function"><span class="hljs-params">(array)</span> -&gt;</span>
flattened = []
<span class="hljs-keyword">for</span> element <span class="hljs-keyword">in</span> array
<span class="hljs-keyword">if</span> <span class="hljs-string">'[object Array]'</span> <span class="hljs-keyword">is</span> Object::toString.call element
<span class="hljs-keyword">if</span> <span class="hljs-string">&#x27;[object Array]&#x27;</span> <span class="hljs-keyword">is</span> Object::toString.call element
flattened = flattened.concat flatten element
<span class="hljs-keyword">else</span>
flattened.push element
@ -289,15 +289,15 @@ Handy for getting a list of <code>children</code> from the nodes.</p>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>Delete a key from an object, returning the value. Useful when a node is
looking for a particular method in an options hash.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.del = <span class="hljs-function"><span class="hljs-params">(obj, key)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.del = <span class="hljs-function"><span class="hljs-params">(obj, key)</span> -&gt;</span>
val = obj[key]
<span class="hljs-keyword">delete</span> obj[key]
val</pre></div></div>
@ -308,15 +308,15 @@ looking for a particular method in an options hash.</p>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>Typical Array::some</p>
</div>
<div class="content"><div class='highlight'><pre>exports.some = Array::some ? (fn) -&gt;
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">for</span> e <span class="hljs-keyword">in</span> <span class="hljs-keyword">this</span> <span class="hljs-keyword">when</span> fn e
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.some = Array::some ? (fn) -&gt;
<span class="hljs-keyword">return</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">for</span> e <span class="hljs-keyword">in</span> this <span class="hljs-keyword">when</span> fn e
<span class="hljs-literal">false</span></pre></div></div>
</li>
@ -325,8 +325,8 @@ looking for a particular method in an options hash.</p>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-13">&#x00a7;</a>
</div>
<p>Helper function for extracting code from Literate CoffeeScript by stripping
out all non-code blocks, producing a string of CoffeeScript code that can
@ -334,7 +334,7 @@ be compiled “normally.”</p>
</div>
<div class="content"><div class='highlight'><pre>exports.invertLiterate = <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.invertLiterate = <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
out = []
blankLine = <span class="hljs-regexp">/^\s*$/</span>
indented = <span class="hljs-regexp">/^[\t ]/</span>
@ -347,19 +347,19 @@ be compiled “normally.”</p>
[\ \t] <span class="hljs-comment"># followed by a space or a tab.</span>
///</span>
insideComment = <span class="hljs-literal">no</span>
<span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> code.split(<span class="hljs-string">'\n'</span>)
<span class="hljs-keyword">for</span> line <span class="hljs-keyword">in</span> code.split(<span class="hljs-string">&#x27;\n&#x27;</span>)
<span class="hljs-keyword">if</span> blankLine.test(line)
insideComment = <span class="hljs-literal">no</span>
out.push line
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> insideComment <span class="hljs-keyword">or</span> listItemStart.test(line)
insideComment = <span class="hljs-literal">yes</span>
out.push <span class="hljs-string">"# <span class="hljs-subst">#{line}</span>"</span>
out.push <span class="hljs-string">&quot;# <span class="hljs-subst">#{line}</span>&quot;</span>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> insideComment <span class="hljs-keyword">and</span> indented.test(line)
out.push line
<span class="hljs-keyword">else</span>
insideComment = <span class="hljs-literal">yes</span>
out.push <span class="hljs-string">"# <span class="hljs-subst">#{line}</span>"</span>
out.join <span class="hljs-string">'\n'</span></pre></div></div>
out.push <span class="hljs-string">&quot;# <span class="hljs-subst">#{line}</span>&quot;</span>
out.join <span class="hljs-string">&#x27;\n&#x27;</span></pre></div></div>
</li>
@ -367,8 +367,8 @@ be compiled “normally.”</p>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-14">&#x00a7;</a>
</div>
<p>Merge two jison-style location data objects together.
If <code>last</code> is not provided, this will simply return <code>first</code>.</p>
@ -396,20 +396,20 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-15">&#x00a7;</a>
</div>
<p>Build a list of all comments attached to tokens.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.extractAllCommentTokens = <span class="hljs-function"><span class="hljs-params">(tokens)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.extractAllCommentTokens = <span class="hljs-function"><span class="hljs-params">(tokens)</span> -&gt;</span>
allCommentsObj = {}
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token.comments
<span class="hljs-keyword">for</span> comment <span class="hljs-keyword">in</span> token.comments
commentKey = comment.locationData.range[<span class="hljs-number">0</span>]
allCommentsObj[commentKey] = comment
sortedKeys = Object.keys(allCommentsObj).sort (a, b) -&gt; a - b
sortedKeys = <span class="hljs-built_in">Object</span>.keys(allCommentsObj).sort (a, b) -&gt; a - b
<span class="hljs-keyword">for</span> key <span class="hljs-keyword">in</span> sortedKeys
allCommentsObj[key]</pre></div></div>
@ -419,8 +419,8 @@ If <code>last</code> is not provided, this will simply return <code>first</code>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-16">&#x00a7;</a>
</div>
<p>Get a lookup hash for a token based on its location data.
Multiple tokens might have the same location hash, but using exclusive
@ -430,7 +430,7 @@ actual source tokens.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">buildLocationHash</span> = <span class="hljs-params">(loc)</span> -&gt;</span>
<span class="hljs-string">"<span class="hljs-subst">#{loc.range[<span class="hljs-number">0</span>]}</span>-<span class="hljs-subst">#{loc.range[<span class="hljs-number">1</span>]}</span>"</span></pre></div></div>
<span class="hljs-string">&quot;<span class="hljs-subst">#{loc.range[<span class="hljs-number">0</span>]}</span>-<span class="hljs-subst">#{loc.range[<span class="hljs-number">1</span>]}</span>&quot;</span></pre></div></div>
</li>
@ -438,15 +438,15 @@ actual source tokens.</p>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-17">&#x00a7;</a>
</div>
<p>Build a dictionary of extra token properties organized by tokens locations
used as lookup hashes.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.buildTokenDataDictionary = buildTokenDataDictionary = <span class="hljs-function"><span class="hljs-params">(tokens)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.buildTokenDataDictionary = buildTokenDataDictionary = <span class="hljs-function"><span class="hljs-params">(tokens)</span> -&gt;</span>
tokenData = {}
<span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token.comments
tokenHash = buildLocationHash token[<span class="hljs-number">2</span>]</pre></div></div>
@ -457,8 +457,8 @@ used as lookup hashes.</p>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-18">&#x00a7;</a>
</div>
<p>Multiple tokens might have the same location hash, such as the generated
<code>JS</code> tokens added at the start or end of the token stream to hold
@ -475,8 +475,8 @@ comments that start or end a file.</p>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-19">&#x00a7;</a>
</div>
<p>For “overlapping” tokens, that is tokens with the same location data
and therefore matching <code>tokenHash</code>es, merge the comments from both/all
@ -494,8 +494,8 @@ they will get sorted out later.</p>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-20">&#x00a7;</a>
</div>
<p>This returns a function which takes an object as a parameter, and if that
object is an AST node, updates that objects locationData.
@ -503,7 +503,7 @@ The object is returned either way.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.addDataToNode = <span class="hljs-function"><span class="hljs-params">(parserState, firstLocationData, firstValue, lastLocationData, lastValue, forceUpdateLocation = <span class="hljs-literal">yes</span>)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.addDataToNode = <span class="hljs-function"><span class="hljs-params">(parserState, firstLocationData, firstValue, lastLocationData, lastValue, forceUpdateLocation = <span class="hljs-literal">yes</span>)</span> -&gt;</span>
(obj) -&gt;</pre></div></div>
</li>
@ -512,8 +512,8 @@ The object is returned either way.</p>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-21">&#x00a7;</a>
</div>
<p>Add location data.</p>
@ -531,8 +531,8 @@ The object is returned either way.</p>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-22">&#x00a7;</a>
</div>
<p>Add comments, building the dictionary of token data if it hasnt been
built yet.</p>
@ -546,7 +546,7 @@ built yet.</p>
attachCommentsToNode parserState.tokenData[objHash].comments, obj
obj
exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function"><span class="hljs-params">(comments, node)</span> -&gt;</span>
<span class="hljs-built_in">exports</span>.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function"><span class="hljs-params">(comments, node)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> comments? <span class="hljs-keyword">or</span> comments.length <span class="hljs-keyword">is</span> <span class="hljs-number">0</span>
node.comments ?= []
node.comments.push comments...</pre></div></div>
@ -557,23 +557,23 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-23">&#x00a7;</a>
</div>
<p>Convert jison location data to a string.
<code>obj</code> can be a token, or a locationData.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.locationDataToString = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span>
<span class="hljs-keyword">if</span> (<span class="hljs-string">"2"</span> <span class="hljs-keyword">of</span> obj) <span class="hljs-keyword">and</span> (<span class="hljs-string">"first_line"</span> <span class="hljs-keyword">of</span> obj[<span class="hljs-number">2</span>]) <span class="hljs-keyword">then</span> locationData = obj[<span class="hljs-number">2</span>]
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-string">"first_line"</span> <span class="hljs-keyword">of</span> obj <span class="hljs-keyword">then</span> locationData = obj
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.locationDataToString = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span>
<span class="hljs-keyword">if</span> (<span class="hljs-string">&quot;2&quot;</span> <span class="hljs-keyword">of</span> obj) <span class="hljs-keyword">and</span> (<span class="hljs-string">&quot;first_line&quot;</span> <span class="hljs-keyword">of</span> obj[<span class="hljs-number">2</span>]) <span class="hljs-keyword">then</span> locationData = obj[<span class="hljs-number">2</span>]
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> <span class="hljs-string">&quot;first_line&quot;</span> <span class="hljs-keyword">of</span> obj <span class="hljs-keyword">then</span> locationData = obj
<span class="hljs-keyword">if</span> locationData
<span class="hljs-string">"<span class="hljs-subst">#{locationData.first_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{locationData.first_column + <span class="hljs-number">1</span>}</span>-"</span> +
<span class="hljs-string">"<span class="hljs-subst">#{locationData.last_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{locationData.last_column + <span class="hljs-number">1</span>}</span>"</span>
<span class="hljs-string">&quot;<span class="hljs-subst">#{locationData.first_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{locationData.first_column + <span class="hljs-number">1</span>}</span>-&quot;</span> +
<span class="hljs-string">&quot;<span class="hljs-subst">#{locationData.last_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{locationData.last_column + <span class="hljs-number">1</span>}</span>&quot;</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"No location data"</span></pre></div></div>
<span class="hljs-string">&quot;No location data&quot;</span></pre></div></div>
</li>
@ -581,22 +581,22 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-24">&#x00a7;</a>
</div>
<p>A <code>.coffee.md</code> compatible version of <code>basename</code>, that returns the file sans-extension.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.baseFileName = <span class="hljs-function"><span class="hljs-params">(file, stripExt = <span class="hljs-literal">no</span>, useWinPathSep = <span class="hljs-literal">no</span>)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.baseFileName = <span class="hljs-function"><span class="hljs-params">(file, stripExt = <span class="hljs-literal">no</span>, useWinPathSep = <span class="hljs-literal">no</span>)</span> -&gt;</span>
pathSep = <span class="hljs-keyword">if</span> useWinPathSep <span class="hljs-keyword">then</span> <span class="hljs-regexp">/\\|\//</span> <span class="hljs-keyword">else</span> <span class="hljs-regexp">/\//</span>
parts = file.split(pathSep)
file = parts[parts.length - <span class="hljs-number">1</span>]
<span class="hljs-keyword">return</span> file <span class="hljs-keyword">unless</span> stripExt <span class="hljs-keyword">and</span> file.indexOf(<span class="hljs-string">'.'</span>) &gt;= <span class="hljs-number">0</span>
parts = file.split(<span class="hljs-string">'.'</span>)
<span class="hljs-keyword">return</span> file <span class="hljs-keyword">unless</span> stripExt <span class="hljs-keyword">and</span> file.indexOf(<span class="hljs-string">&#x27;.&#x27;</span>) &gt;= <span class="hljs-number">0</span>
parts = file.split(<span class="hljs-string">&#x27;.&#x27;</span>)
parts.pop()
parts.pop() <span class="hljs-keyword">if</span> parts[parts.length - <span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'coffee'</span> <span class="hljs-keyword">and</span> parts.length &gt; <span class="hljs-number">1</span>
parts.join(<span class="hljs-string">'.'</span>)</pre></div></div>
parts.pop() <span class="hljs-keyword">if</span> parts[parts.length - <span class="hljs-number">1</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;coffee&#x27;</span> <span class="hljs-keyword">and</span> parts.length &gt; <span class="hljs-number">1</span>
parts.join(<span class="hljs-string">&#x27;.&#x27;</span>)</pre></div></div>
</li>
@ -604,14 +604,14 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-25">&#x00a7;</a>
</div>
<p>Determine if a filename represents a CoffeeScript file.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.isCoffee = <span class="hljs-function"><span class="hljs-params">(file)</span> -&gt;</span> <span class="hljs-regexp">/\.((lit)?coffee|coffee\.md)$/</span>.test file</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.isCoffee = <span class="hljs-function"><span class="hljs-params">(file)</span> -&gt;</span> <span class="hljs-regexp">/\.((lit)?coffee|coffee\.md)$/</span>.test file</pre></div></div>
</li>
@ -619,14 +619,14 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-26">&#x00a7;</a>
</div>
<p>Determine if a filename represents a Literate CoffeeScript file.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.isLiterate = <span class="hljs-function"><span class="hljs-params">(file)</span> -&gt;</span> <span class="hljs-regexp">/\.(litcoffee|coffee\.md)$/</span>.test file</pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.isLiterate = <span class="hljs-function"><span class="hljs-params">(file)</span> -&gt;</span> <span class="hljs-regexp">/\.(litcoffee|coffee\.md)$/</span>.test file</pre></div></div>
</li>
@ -634,8 +634,8 @@ exports.attachCommentsToNode = attachCommentsToNode = <span class="hljs-function
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-27">&#x00a7;</a>
</div>
<p>Throws a SyntaxError from a given location.
The errors <code>toString</code> will return an error message following the “standard”
@ -644,8 +644,8 @@ marker showing where the error is.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.throwSyntaxError = <span class="hljs-function"><span class="hljs-params">(message, location)</span> -&gt;</span>
error = <span class="hljs-keyword">new</span> SyntaxError message
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.throwSyntaxError = <span class="hljs-function"><span class="hljs-params">(message, location)</span> -&gt;</span>
error = <span class="hljs-keyword">new</span> <span class="hljs-built_in">SyntaxError</span> message
error.location = location
error.toString = syntaxErrorToString</pre></div></div>
@ -655,8 +655,8 @@ marker showing where the error is.</p>
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-28">&#x00a7;</a>
</div>
<p>Instead of showing the compilers stacktrace, show our custom error message
(this is useful when the error bubbles up in Node.js applications that
@ -674,15 +674,15 @@ compile CoffeeScript for example).</p>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-29">&#x00a7;</a>
</div>
<p>Update a compiler SyntaxError with source code information if it didnt have
it already.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.updateSyntaxError = <span class="hljs-function"><span class="hljs-params">(error, code, filename)</span> -&gt;</span></pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.updateSyntaxError = <span class="hljs-function"><span class="hljs-params">(error, code, filename)</span> -&gt;</span></pre></div></div>
</li>
@ -690,8 +690,8 @@ it already.</p>
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-30">&#x00a7;</a>
</div>
<p>Avoid screwing up the <code>stack</code> property of other errors (i.e. possible bugs).</p>
@ -710,8 +710,8 @@ it already.</p>
last_line ?= first_line
last_column ?= first_column
filename = @filename <span class="hljs-keyword">or</span> <span class="hljs-string">'[stdin]'</span>
codeLine = @code.split(<span class="hljs-string">'\n'</span>)[first_line]
filename = @filename <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;[stdin]&#x27;</span>
codeLine = @code.split(<span class="hljs-string">&#x27;\n&#x27;</span>)[first_line]
start = first_column</pre></div></div>
</li>
@ -720,15 +720,15 @@ it already.</p>
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-31">&#x00a7;</a>
</div>
<p>Show only the first line on multi-line errors.</p>
</div>
<div class="content"><div class='highlight'><pre> end = <span class="hljs-keyword">if</span> first_line <span class="hljs-keyword">is</span> last_line <span class="hljs-keyword">then</span> last_column + <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> codeLine.length
marker = codeLine[...start].replace(<span class="hljs-regexp">/[^\s]/g</span>, <span class="hljs-string">' '</span>) + repeat(<span class="hljs-string">'^'</span>, end - start)</pre></div></div>
marker = codeLine[...start].replace(<span class="hljs-regexp">/[^\s]/g</span>, <span class="hljs-string">&#x27; &#x27;</span>) + repeat(<span class="hljs-string">&#x27;^&#x27;</span>, end - start)</pre></div></div>
</li>
@ -736,8 +736,8 @@ it already.</p>
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-32">&#x00a7;</a>
</div>
<p>Check to see if were running on a color-enabled TTY.</p>
@ -747,48 +747,48 @@ it already.</p>
colorsEnabled = process.stdout?.isTTY <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> process.env?.NODE_DISABLE_COLORS
<span class="hljs-keyword">if</span> @colorful ? colorsEnabled
<span class="hljs-function"> <span class="hljs-title">colorize</span> = <span class="hljs-params">(str)</span> -&gt;</span> <span class="hljs-string">"\x1B[1;31m<span class="hljs-subst">#{str}</span>\x1B[0m"</span>
<span class="hljs-function"> <span class="hljs-title">colorize</span> = <span class="hljs-params">(str)</span> -&gt;</span> <span class="hljs-string">&quot;\x1B[1;31m<span class="hljs-subst">#{str}</span>\x1B[0m&quot;</span>
codeLine = codeLine[...start] + colorize(codeLine[start...end]) + codeLine[end..]
marker = colorize marker
<span class="hljs-string">"""
<span class="hljs-string">&quot;&quot;&quot;
<span class="hljs-subst">#{filename}</span>:<span class="hljs-subst">#{first_line + <span class="hljs-number">1</span>}</span>:<span class="hljs-subst">#{first_column + <span class="hljs-number">1</span>}</span>: error: <span class="hljs-subst">#{@message}</span>
<span class="hljs-subst">#{codeLine}</span>
<span class="hljs-subst">#{marker}</span>
"""</span>
&quot;&quot;&quot;</span>
exports.nameWhitespaceCharacter = <span class="hljs-function"><span class="hljs-params">(string)</span> -&gt;</span>
<span class="hljs-built_in">exports</span>.nameWhitespaceCharacter = <span class="hljs-function"><span class="hljs-params">(string)</span> -&gt;</span>
<span class="hljs-keyword">switch</span> string
<span class="hljs-keyword">when</span> <span class="hljs-string">' '</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'space'</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'\n'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'newline'</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'\r'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'carriage return'</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'\t'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'tab'</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">&#x27; &#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-string">&#x27;space&#x27;</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">&#x27;\n&#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-string">&#x27;newline&#x27;</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">&#x27;\r&#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-string">&#x27;carriage return&#x27;</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">&#x27;\t&#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-string">&#x27;tab&#x27;</span>
<span class="hljs-keyword">else</span> string
exports.parseNumber = <span class="hljs-function"><span class="hljs-params">(string)</span> -&gt;</span>
<span class="hljs-keyword">return</span> NaN <span class="hljs-keyword">unless</span> string?
<span class="hljs-built_in">exports</span>.parseNumber = <span class="hljs-function"><span class="hljs-params">(string)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-literal">NaN</span> <span class="hljs-keyword">unless</span> string?
base = <span class="hljs-keyword">switch</span> string.charAt <span class="hljs-number">1</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'b'</span> <span class="hljs-keyword">then</span> <span class="hljs-number">2</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'o'</span> <span class="hljs-keyword">then</span> <span class="hljs-number">8</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">'x'</span> <span class="hljs-keyword">then</span> <span class="hljs-number">16</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">&#x27;b&#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-number">2</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">&#x27;o&#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-number">8</span>
<span class="hljs-keyword">when</span> <span class="hljs-string">&#x27;x&#x27;</span> <span class="hljs-keyword">then</span> <span class="hljs-number">16</span>
<span class="hljs-keyword">else</span> <span class="hljs-literal">null</span>
<span class="hljs-keyword">if</span> base?
parseInt string[<span class="hljs-number">2.</span>.].replace(<span class="hljs-regexp">/_/g</span>, <span class="hljs-string">''</span>), base
<span class="hljs-built_in">parseInt</span> string[<span class="hljs-number">2.</span>.].replace(<span class="hljs-regexp">/_/g</span>, <span class="hljs-string">&#x27;&#x27;</span>), base
<span class="hljs-keyword">else</span>
parseFloat string.replace(<span class="hljs-regexp">/_/g</span>, <span class="hljs-string">''</span>)
<span class="hljs-built_in">parseFloat</span> string.replace(<span class="hljs-regexp">/_/g</span>, <span class="hljs-string">&#x27;&#x27;</span>)
exports.isFunction = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'[object Function]'</span>
exports.isNumber = isNumber = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'[object Number]'</span>
exports.isString = isString = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'[object String]'</span>
exports.isBoolean = isBoolean = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> obj <span class="hljs-keyword">is</span> <span class="hljs-literal">yes</span> <span class="hljs-keyword">or</span> obj <span class="hljs-keyword">is</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">or</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">'[object Boolean]'</span>
exports.isPlainObject = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> <span class="hljs-keyword">typeof</span> obj <span class="hljs-keyword">is</span> <span class="hljs-string">'object'</span> <span class="hljs-keyword">and</span> !!obj <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> Array.isArray(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isNumber(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isString(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isBoolean(obj)
<span class="hljs-built_in">exports</span>.isFunction = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;[object Function]&#x27;</span>
<span class="hljs-built_in">exports</span>.isNumber = isNumber = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;[object Number]&#x27;</span>
<span class="hljs-built_in">exports</span>.isString = isString = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;[object String]&#x27;</span>
<span class="hljs-built_in">exports</span>.isBoolean = isBoolean = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> obj <span class="hljs-keyword">is</span> <span class="hljs-literal">yes</span> <span class="hljs-keyword">or</span> obj <span class="hljs-keyword">is</span> <span class="hljs-literal">no</span> <span class="hljs-keyword">or</span> Object::toString.call(obj) <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;[object Boolean]&#x27;</span>
<span class="hljs-built_in">exports</span>.isPlainObject = <span class="hljs-function"><span class="hljs-params">(obj)</span> -&gt;</span> <span class="hljs-keyword">typeof</span> obj <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;object&#x27;</span> <span class="hljs-keyword">and</span> !!obj <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> <span class="hljs-built_in">Array</span>.isArray(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isNumber(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isString(obj) <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> isBoolean(obj)
<span class="hljs-function">
<span class="hljs-title">unicodeCodePointToUnicodeEscapes</span> = <span class="hljs-params">(codePoint)</span> -&gt;</span>
<span class="hljs-function"> <span class="hljs-title">toUnicodeEscape</span> = <span class="hljs-params">(val)</span> -&gt;</span>
str = val.toString <span class="hljs-number">16</span>
<span class="hljs-string">"\\u<span class="hljs-subst">#{repeat <span class="hljs-string">'0'</span>, <span class="hljs-number">4</span> - str.length}</span><span class="hljs-subst">#{str}</span>"</span>
<span class="hljs-string">&quot;\\u<span class="hljs-subst">#{repeat <span class="hljs-string">&#x27;0&#x27;</span>, <span class="hljs-number">4</span> - str.length}</span><span class="hljs-subst">#{str}</span>&quot;</span>
<span class="hljs-keyword">return</span> toUnicodeEscape(codePoint) <span class="hljs-keyword">if</span> codePoint &lt; <span class="hljs-number">0x10000</span></pre></div></div>
</li>
@ -797,16 +797,16 @@ exports.isPlainObject = <span class="hljs-function"><span class="hljs-params">(o
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-33">&#x00a7;</a>
</div>
<p>surrogate pair</p>
</div>
<div class="content"><div class='highlight'><pre> high = Math.floor((codePoint - <span class="hljs-number">0x10000</span>) / <span class="hljs-number">0x400</span>) + <span class="hljs-number">0xD800</span>
<div class="content"><div class='highlight'><pre> high = <span class="hljs-built_in">Math</span>.floor((codePoint - <span class="hljs-number">0x10000</span>) / <span class="hljs-number">0x400</span>) + <span class="hljs-number">0xD800</span>
low = (codePoint - <span class="hljs-number">0x10000</span>) % <span class="hljs-number">0x400</span> + <span class="hljs-number">0xDC00</span>
<span class="hljs-string">"<span class="hljs-subst">#{toUnicodeEscape(high)}</span><span class="hljs-subst">#{toUnicodeEscape(low)}</span>"</span></pre></div></div>
<span class="hljs-string">&quot;<span class="hljs-subst">#{toUnicodeEscape(high)}</span><span class="hljs-subst">#{toUnicodeEscape(low)}</span>&quot;</span></pre></div></div>
</li>
@ -814,21 +814,21 @@ exports.isPlainObject = <span class="hljs-function"><span class="hljs-params">(o
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-34">&#x00a7;</a>
</div>
<p>Replace <code>\u{...}</code> with <code>\uxxxx[\uxxxx]</code> in regexes without <code>u</code> flag</p>
</div>
<div class="content"><div class='highlight'><pre>exports.replaceUnicodeCodePointEscapes = <span class="hljs-function"><span class="hljs-params">(str, {flags, error, delimiter = <span class="hljs-string">''</span>} = {})</span> -&gt;</span>
shouldReplace = flags? <span class="hljs-keyword">and</span> <span class="hljs-string">'u'</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> flags
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.replaceUnicodeCodePointEscapes = <span class="hljs-function"><span class="hljs-params">(str, {flags, error, delimiter = <span class="hljs-string">&#x27;&#x27;</span>} = {})</span> -&gt;</span>
shouldReplace = flags? <span class="hljs-keyword">and</span> <span class="hljs-string">&#x27;u&#x27;</span> <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> flags
str.replace UNICODE_CODE_POINT_ESCAPE, <span class="hljs-function"><span class="hljs-params">(match, escapedBackslash, codePointHex, offset)</span> -&gt;</span>
<span class="hljs-keyword">return</span> escapedBackslash <span class="hljs-keyword">if</span> escapedBackslash
codePointDecimal = parseInt codePointHex, <span class="hljs-number">16</span>
codePointDecimal = <span class="hljs-built_in">parseInt</span> codePointHex, <span class="hljs-number">16</span>
<span class="hljs-keyword">if</span> codePointDecimal &gt; <span class="hljs-number">0x10ffff</span>
error <span class="hljs-string">"unicode code point escapes greater than \\u{10ffff} are not allowed"</span>,
error <span class="hljs-string">&quot;unicode code point escapes greater than \\u{10ffff} are not allowed&quot;</span>,
offset: offset + delimiter.length
length: codePointHex.length + <span class="hljs-number">4</span>
<span class="hljs-keyword">return</span> match <span class="hljs-keyword">unless</span> shouldReplace

View file

@ -112,26 +112,26 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
<p>Node.js Implementation</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./coffeescript'</span>
fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./coffeescript&#x27;</span>
fs = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;fs&#x27;</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;vm&#x27;</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;path&#x27;</span>
helpers = CoffeeScript.helpers
CoffeeScript.transpile = <span class="hljs-function"><span class="hljs-params">(js, options)</span> -&gt;</span>
<span class="hljs-keyword">try</span>
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">'@babel/core'</span>
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;@babel/core&#x27;</span>
<span class="hljs-keyword">catch</span>
<span class="hljs-keyword">try</span>
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">'babel-core'</span>
babel = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;babel-core&#x27;</span>
<span class="hljs-keyword">catch</span></pre></div></div>
</li>
@ -140,15 +140,15 @@ CoffeeScript.transpile = <span class="hljs-function"><span class="hljs-params">(
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>This error is only for Node, as CLI users will see a different error
earlier if they dont have Babel installed.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">'To use the transpile option, you must have the \'@babel/core\' module installed'</span>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&#x27;To use the transpile option, you must have the \&#x27;@babel/core\&#x27; module installed&#x27;</span>
babel.transform js, options</pre></div></div>
</li>
@ -157,8 +157,8 @@ earlier if they dont have Babel installed.</p>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>The <code>compile</code> method shared by the CLI, Node and browser APIs.</p>
@ -172,8 +172,8 @@ earlier if they dont have Babel installed.</p>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>The <code>compile</code> method particular to the Node API.</p>
@ -187,8 +187,8 @@ earlier if they dont have Babel installed.</p>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>Pass a reference to Babel into the compiler, so that the transpile option
is available in the Node API. We need to do this so that tools like Webpack
@ -207,8 +207,8 @@ require Babel.</p>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Compile and execute a string of CoffeeScript (on the server), correctly
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p>
@ -224,15 +224,15 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Set the filename.</p>
</div>
<div class="content"><div class='highlight'><pre> mainModule.filename = process.argv[<span class="hljs-number">1</span>] =
<span class="hljs-keyword">if</span> options.filename <span class="hljs-keyword">then</span> fs.realpathSync(options.filename) <span class="hljs-keyword">else</span> <span class="hljs-string">'&lt;anonymous&gt;'</span></pre></div></div>
<span class="hljs-keyword">if</span> options.filename <span class="hljs-keyword">then</span> fs.realpathSync(options.filename) <span class="hljs-keyword">else</span> <span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span></pre></div></div>
</li>
@ -240,8 +240,8 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Clear the module cache.</p>
@ -255,8 +255,8 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p>Assign paths for node_modules loading</p>
@ -265,8 +265,8 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<div class="content"><div class='highlight'><pre> dir = <span class="hljs-keyword">if</span> options.filename?
path.dirname fs.realpathSync options.filename
<span class="hljs-keyword">else</span>
fs.realpathSync <span class="hljs-string">'.'</span>
mainModule.paths = <span class="hljs-built_in">require</span>(<span class="hljs-string">'module'</span>)._nodeModulePaths dir</pre></div></div>
fs.realpathSync <span class="hljs-string">&#x27;.&#x27;</span>
mainModule.paths = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;module&#x27;</span>)._nodeModulePaths dir</pre></div></div>
</li>
@ -274,8 +274,8 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>Save the options for compiling child imports.</p>
@ -289,8 +289,8 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>Compile.</p>
@ -308,15 +308,15 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
The CoffeeScript REPL uses this to run the input.</p>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript.eval = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
<div class="content"><div class='highlight'><pre>CoffeeScript.<span class="hljs-built_in">eval</span> = <span class="hljs-function"><span class="hljs-params">(code, options = {})</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> code = code.trim()
createContext = vm.Script.createContext ? vm.createContext
@ -330,10 +330,10 @@ The CoffeeScript REPL uses this to run the input.</p>
<span class="hljs-keyword">else</span>
sandbox = createContext()
sandbox[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options.sandbox
sandbox.<span class="hljs-built_in">global</span> = sandbox.root = sandbox.GLOBAL = sandbox
sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox
<span class="hljs-keyword">else</span>
sandbox = <span class="hljs-built_in">global</span>
sandbox.__filename = options.filename || <span class="hljs-string">'eval'</span>
sandbox = global
sandbox.__filename = options.filename || <span class="hljs-string">&#x27;eval&#x27;</span>
sandbox.__dirname = path.dirname sandbox.__filename</pre></div></div>
</li>
@ -342,19 +342,19 @@ The CoffeeScript REPL uses this to run the input.</p>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-13">&#x00a7;</a>
</div>
<p>define module/require only if they chose not to specify their own</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> sandbox <span class="hljs-keyword">isnt</span> <span class="hljs-built_in">global</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">module</span> <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">require</span>
Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
sandbox.<span class="hljs-built_in">module</span> = _module = <span class="hljs-keyword">new</span> Module(options.modulename || <span class="hljs-string">'eval'</span>)
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">unless</span> sandbox <span class="hljs-keyword">isnt</span> global <span class="hljs-keyword">or</span> sandbox.module <span class="hljs-keyword">or</span> sandbox.<span class="hljs-built_in">require</span>
Module = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;module&#x27;</span>
sandbox.module = _module = <span class="hljs-keyword">new</span> Module(options.modulename || <span class="hljs-string">&#x27;eval&#x27;</span>)
sandbox.<span class="hljs-built_in">require</span> = _require = <span class="hljs-function"><span class="hljs-params">(path)</span> -&gt;</span> Module._load path, _module, <span class="hljs-literal">true</span>
_module.filename = sandbox.__filename
<span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'paths'</span>, <span class="hljs-string">'arguments'</span>, <span class="hljs-string">'caller'</span>]
<span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> <span class="hljs-built_in">Object</span>.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">&#x27;paths&#x27;</span>, <span class="hljs-string">&#x27;arguments&#x27;</span>, <span class="hljs-string">&#x27;caller&#x27;</span>]
_require[r] = <span class="hljs-built_in">require</span>[r]</pre></div></div>
</li>
@ -363,8 +363,8 @@ The CoffeeScript REPL uses this to run the input.</p>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-14">&#x00a7;</a>
</div>
<p>use the same hack node currently uses for their own REPL</p>
@ -376,12 +376,12 @@ The CoffeeScript REPL uses this to run the input.</p>
o[k] = v <span class="hljs-keyword">for</span> own k, v <span class="hljs-keyword">of</span> options
o.bare = <span class="hljs-literal">on</span> <span class="hljs-comment"># ensure return value</span>
js = CoffeeScript.compile code, o
<span class="hljs-keyword">if</span> sandbox <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
<span class="hljs-keyword">if</span> sandbox <span class="hljs-keyword">is</span> global
vm.runInThisContext js
<span class="hljs-keyword">else</span>
vm.runInContext js, sandbox
CoffeeScript.register = <span class="hljs-function">-&gt;</span> <span class="hljs-built_in">require</span> <span class="hljs-string">'./register'</span></pre></div></div>
CoffeeScript.register = <span class="hljs-function">-&gt;</span> <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./register&#x27;</span></pre></div></div>
</li>
@ -389,8 +389,8 @@ CoffeeScript.register = <span class="hljs-function">-&gt;</span> <span class="hl
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-15">&#x00a7;</a>
</div>
<p>Throw error with deprecation warning when depending upon implicit <code>require.extensions</code> registration</p>
@ -399,9 +399,9 @@ CoffeeScript.register = <span class="hljs-function">-&gt;</span> <span class="hl
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> <span class="hljs-built_in">require</span>.extensions
<span class="hljs-keyword">for</span> ext <span class="hljs-keyword">in</span> CoffeeScript.FILE_EXTENSIONS <span class="hljs-keyword">then</span> <span class="hljs-keyword">do</span> (ext) -&gt;
<span class="hljs-built_in">require</span>.extensions[ext] ?= <span class="hljs-function">-&gt;</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"""
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;&quot;&quot;
Use CoffeeScript.register() or require the coffeescript/register module to require <span class="hljs-subst">#{ext}</span> files.
"""</span>
&quot;&quot;&quot;</span>
CoffeeScript._compileRawFileContent = <span class="hljs-function"><span class="hljs-params">(raw, filename, options = {})</span> -&gt;</span></pre></div></div>
@ -411,8 +411,8 @@ CoffeeScript._compileRawFileContent = <span class="hljs-function"><span class="h
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-16">&#x00a7;</a>
</div>
<p>Strip the Unicode byte order mark, if this file begins with one.</p>
@ -420,7 +420,7 @@ CoffeeScript._compileRawFileContent = <span class="hljs-function"><span class="h
<div class="content"><div class='highlight'><pre> stripped = <span class="hljs-keyword">if</span> raw.charCodeAt(<span class="hljs-number">0</span>) <span class="hljs-keyword">is</span> <span class="hljs-number">0xFEFF</span> <span class="hljs-keyword">then</span> raw.substring <span class="hljs-number">1</span> <span class="hljs-keyword">else</span> raw
options = Object.assign {}, options,
options = <span class="hljs-built_in">Object</span>.assign {}, options,
filename: filename
literate: helpers.isLiterate filename
sourceFiles: [filename]
@ -436,8 +436,8 @@ CoffeeScript._compileRawFileContent = <span class="hljs-function"><span class="h
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-17">&#x00a7;</a>
</div>
<p>As the filename and code of a dynamically loaded file will be different
from the original file compiled with CoffeeScript.run, add that
@ -450,11 +450,11 @@ information to error so it can be pretty-printed later.</p>
answer
CoffeeScript._compileFile = <span class="hljs-function"><span class="hljs-params">(filename, options = {})</span> -&gt;</span>
raw = fs.readFileSync filename, <span class="hljs-string">'utf8'</span>
raw = fs.readFileSync filename, <span class="hljs-string">&#x27;utf8&#x27;</span>
CoffeeScript._compileRawFileContent raw, filename, options
<span class="hljs-built_in">module</span>.exports = CoffeeScript</pre></div></div>
module.<span class="hljs-built_in">exports</span> = CoffeeScript</pre></div></div>
</li>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -112,13 +112,13 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre>{repeat} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span></pre></div></div>
<div class="content"><div class='highlight'><pre>{repeat} = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./helpers&#x27;</span></pre></div></div>
</li>
@ -126,8 +126,8 @@
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>A simple <strong>OptionParser</strong> class to parse option flags from the command-line.
Use it like so:</p>
@ -140,7 +140,7 @@ command-line arguments in <code>src/command.coffee</code>.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.OptionParser = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OptionParser</span></span></pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.OptionParser = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">OptionParser</span></span></pre></div></div>
</li>
@ -148,8 +148,8 @@ command-line arguments in <code>src/command.coffee</code>.</p>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>Initialize with a list of valid options, in the form:</p>
<pre><code>[short-flag, long-flag, description]
@ -166,8 +166,8 @@ command-line arguments in <code>src/command.coffee</code>.</p>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Parse the list of arguments, populating an <code>options</code> object with all of the
specified options, and return it. Options after the first non-option
@ -186,8 +186,8 @@ youre responsible for interpreting the options object.</p>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>The CoffeeScript option parser is a little odd; options after the first
non-option argument are treated as non-option arguments themselves.
@ -208,8 +208,8 @@ line <code>#!/usr/bin/env coffee</code>, or <code>#!/absolute/path/to/coffee</co
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>The <code>argument</code> field is added to the rule instance non-destructively by
<code>normalizeArguments</code>.</p>
@ -226,7 +226,7 @@ line <code>#!/usr/bin/env coffee</code>, or <code>#!/absolute/path/to/coffee</co
<span class="hljs-keyword">else</span>
options[name] = <span class="hljs-literal">true</span>
<span class="hljs-keyword">if</span> positional[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'--'</span>
<span class="hljs-keyword">if</span> positional[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;--&#x27;</span>
options.doubleDashed = <span class="hljs-literal">yes</span>
positional = positional[<span class="hljs-number">1.</span>.]
@ -239,8 +239,8 @@ line <code>#!/usr/bin/env coffee</code>, or <code>#!/absolute/path/to/coffee</co
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Return the help text for this <strong>OptionParser</strong>, listing and describing all
of the valid options, for <code>--help</code> and such.</p>
@ -249,13 +249,13 @@ of the valid options, for <code>--help</code> and such.</p>
<div class="content"><div class='highlight'><pre> help: <span class="hljs-function">-&gt;</span>
lines = []
lines.unshift <span class="hljs-string">"<span class="hljs-subst">#{@banner}</span>\n"</span> <span class="hljs-keyword">if</span> @banner
lines.unshift <span class="hljs-string">&quot;<span class="hljs-subst">#{@banner}</span>\n&quot;</span> <span class="hljs-keyword">if</span> @banner
<span class="hljs-keyword">for</span> rule <span class="hljs-keyword">in</span> @rules.ruleList
spaces = <span class="hljs-number">15</span> - rule.longFlag.length
spaces = <span class="hljs-keyword">if</span> spaces &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> repeat <span class="hljs-string">' '</span>, spaces <span class="hljs-keyword">else</span> <span class="hljs-string">''</span>
letPart = <span class="hljs-keyword">if</span> rule.shortFlag <span class="hljs-keyword">then</span> rule.shortFlag + <span class="hljs-string">', '</span> <span class="hljs-keyword">else</span> <span class="hljs-string">' '</span>
lines.push <span class="hljs-string">' '</span> + letPart + rule.longFlag + spaces + rule.description
<span class="hljs-string">"\n<span class="hljs-subst">#{ lines.join(<span class="hljs-string">'\n'</span>) }</span>\n"</span></pre></div></div>
spaces = <span class="hljs-keyword">if</span> spaces &gt; <span class="hljs-number">0</span> <span class="hljs-keyword">then</span> repeat <span class="hljs-string">&#x27; &#x27;</span>, spaces <span class="hljs-keyword">else</span> <span class="hljs-string">&#x27;&#x27;</span>
letPart = <span class="hljs-keyword">if</span> rule.shortFlag <span class="hljs-keyword">then</span> rule.shortFlag + <span class="hljs-string">&#x27;, &#x27;</span> <span class="hljs-keyword">else</span> <span class="hljs-string">&#x27; &#x27;</span>
lines.push <span class="hljs-string">&#x27; &#x27;</span> + letPart + rule.longFlag + spaces + rule.description
<span class="hljs-string">&quot;\n<span class="hljs-subst">#{ lines.join(<span class="hljs-string">&#x27;\n&#x27;</span>) }</span>\n&quot;</span></pre></div></div>
</li>
@ -263,8 +263,8 @@ of the valid options, for <code>--help</code> and such.</p>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<h2 id="helpers">Helpers</h2>
@ -276,8 +276,8 @@ of the valid options, for <code>--help</code> and such.</p>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
</div>
@ -288,8 +288,8 @@ of the valid options, for <code>--help</code> and such.</p>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>Regex matchers for option flags on the command line and their rules.</p>
@ -305,8 +305,8 @@ MULTI_FLAG = <span class="hljs-regexp">/^-(\w{2,})/</span></pre></div></div>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>Matches the long flag part of a rule for an option with an argument. Not
applied to anything in process.argv.</p>
@ -321,8 +321,8 @@ applied to anything in process.argv.</p>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>Build and return the list of option rules. If the optional <em>short-flag</em> is
unspecified, leave it out by padding with <code>null</code>.</p>
@ -342,8 +342,8 @@ unspecified, leave it out by padding with <code>null</code>.</p>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-13">&#x00a7;</a>
</div>
<p><code>shortFlag</code> is null if not provided in the rule.</p>
@ -351,8 +351,8 @@ unspecified, leave it out by padding with <code>null</code>.</p>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">for</span> flag <span class="hljs-keyword">in</span> [rule.shortFlag, rule.longFlag] <span class="hljs-keyword">when</span> flag?
<span class="hljs-keyword">if</span> flagDict[flag]?
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"flag <span class="hljs-subst">#{flag}</span> for switch <span class="hljs-subst">#{rule.name}</span>
was already declared for switch <span class="hljs-subst">#{flagDict[flag].name}</span>"</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;flag <span class="hljs-subst">#{flag}</span> for switch <span class="hljs-subst">#{rule.name}</span>
was already declared for switch <span class="hljs-subst">#{flagDict[flag].name}</span>&quot;</span>
flagDict[flag] = rule
{ruleList, flagDict}</pre></div></div>
@ -363,8 +363,8 @@ unspecified, leave it out by padding with <code>null</code>.</p>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-14">&#x00a7;</a>
</div>
<p>Build a rule from a <code>-o</code> short flag, a <code>--output [DIR]</code> long flag, and the
description of what the option does.</p>
@ -376,7 +376,7 @@ description of what the option does.</p>
shortFlag = shortFlag?.match(SHORT_FLAG)[<span class="hljs-number">1</span>]
longFlag = longFlag.match(LONG_FLAG)[<span class="hljs-number">1</span>]
{
name: longFlag.replace <span class="hljs-regexp">/^--/</span>, <span class="hljs-string">''</span>
name: longFlag.replace <span class="hljs-regexp">/^--/</span>, <span class="hljs-string">&#x27;&#x27;</span>
shortFlag: shortFlag
longFlag: longFlag
description: description
@ -396,8 +396,8 @@ description of what the option does.</p>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-15">&#x00a7;</a>
</div>
<p>If the previous argument given to the script was an option that uses the
next command-line argument as its argument, create copy of the options
@ -406,19 +406,19 @@ rule with an <code>argument</code> field.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> needsArgOpt?
withArg = Object.assign {}, needsArgOpt.rule, {argument: arg}
withArg = <span class="hljs-built_in">Object</span>.assign {}, needsArgOpt.rule, {argument: arg}
rules.push withArg
needsArgOpt = <span class="hljs-literal">null</span>
<span class="hljs-keyword">continue</span>
multiFlags = arg.match(MULTI_FLAG)?[<span class="hljs-number">1</span>]
.split(<span class="hljs-string">''</span>)
.map (flagName) -&gt; <span class="hljs-string">"-<span class="hljs-subst">#{flagName}</span>"</span>
.split(<span class="hljs-string">&#x27;&#x27;</span>)
.map (flagName) -&gt; <span class="hljs-string">&quot;-<span class="hljs-subst">#{flagName}</span>&quot;</span>
<span class="hljs-keyword">if</span> multiFlags?
multiOpts = multiFlags.map (flag) -&gt;
rule = flagDict[flag]
<span class="hljs-keyword">unless</span> rule?
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"unrecognized option <span class="hljs-subst">#{flag}</span> in multi-flag <span class="hljs-subst">#{arg}</span>"</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;unrecognized option <span class="hljs-subst">#{flag}</span> in multi-flag <span class="hljs-subst">#{arg}</span>&quot;</span>
{rule, flag}</pre></div></div>
</li>
@ -427,8 +427,8 @@ rule with an <code>argument</code> field.</p>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-16">&#x00a7;</a>
</div>
<p>Only the last flag in a multi-flag may have an argument.</p>
@ -437,8 +437,8 @@ rule with an <code>argument</code> field.</p>
<div class="content"><div class='highlight'><pre> [innerOpts..., lastOpt] = multiOpts
<span class="hljs-keyword">for</span> {rule, flag} <span class="hljs-keyword">in</span> innerOpts
<span class="hljs-keyword">if</span> rule.hasArgument
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"cannot use option <span class="hljs-subst">#{flag}</span> in multi-flag <span class="hljs-subst">#{arg}</span> except
as the last option, because it needs an argument"</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;cannot use option <span class="hljs-subst">#{flag}</span> in multi-flag <span class="hljs-subst">#{arg}</span> except
as the last option, because it needs an argument&quot;</span>
rules.push rule
<span class="hljs-keyword">if</span> lastOpt.rule.hasArgument
needsArgOpt = lastOpt
@ -447,7 +447,7 @@ rule with an <code>argument</code> field.</p>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> ([LONG_FLAG, SHORT_FLAG].some (pat) -&gt; arg.match(pat)?)
singleRule = flagDict[arg]
<span class="hljs-keyword">unless</span> singleRule?
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"unrecognized option <span class="hljs-subst">#{arg}</span>"</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;unrecognized option <span class="hljs-subst">#{arg}</span>&quot;</span>
<span class="hljs-keyword">if</span> singleRule.hasArgument
needsArgOpt = {rule: singleRule, flag: arg}
<span class="hljs-keyword">else</span>
@ -460,8 +460,8 @@ rule with an <code>argument</code> field.</p>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-17">&#x00a7;</a>
</div>
<p>This is a positional argument.</p>
@ -471,8 +471,8 @@ rule with an <code>argument</code> field.</p>
<span class="hljs-keyword">break</span>
<span class="hljs-keyword">if</span> needsArgOpt?
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"value required for <span class="hljs-subst">#{needsArgOpt.flag}</span>, but it was the last
argument provided"</span>
<span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;value required for <span class="hljs-subst">#{needsArgOpt.flag}</span>, but it was the last
argument provided&quot;</span>
{rules, positional}</pre></div></div>
</li>

0
docs/v2/annotated-source/public/fonts/roboto-black.eot Executable file → Normal file
View file

0
docs/v2/annotated-source/public/fonts/roboto-black.ttf Executable file → Normal file
View file

View file

View file

@ -112,16 +112,16 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./'</span>
child_process = <span class="hljs-built_in">require</span> <span class="hljs-string">'child_process'</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span></pre></div></div>
<div class="content"><div class='highlight'><pre>CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./&#x27;</span>
child_process = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;child_process&#x27;</span>
helpers = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./helpers&#x27;</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;path&#x27;</span></pre></div></div>
</li>
@ -129,17 +129,17 @@ path = <span class="hljs-built_in">require</span> <span class="hljs-str
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>Load and run a CoffeeScript file for Node, stripping any <code>BOM</code>s.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">loadFile</span> = <span class="hljs-params">(<span class="hljs-built_in">module</span>, filename)</span> -&gt;</span>
options = <span class="hljs-built_in">module</span>.options <span class="hljs-keyword">or</span> getRootModule(<span class="hljs-built_in">module</span>).options
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">loadFile</span> = <span class="hljs-params">(module, filename)</span> -&gt;</span>
options = module.options <span class="hljs-keyword">or</span> getRootModule(module).options
answer = CoffeeScript._compileFile filename, options
<span class="hljs-built_in">module</span>._compile answer, filename</pre></div></div>
module._compile answer, filename</pre></div></div>
</li>
@ -147,8 +147,8 @@ path = <span class="hljs-built_in">require</span> <span class="hljs-str
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>If the installed version of Node supports <code>require.extensions</code>, register
CoffeeScript as an extension.</p>
@ -165,18 +165,18 @@ CoffeeScript as an extension.</p>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Patch Nodes module loader to be able to handle multi-dot extensions.
This is a horrible thing that should not be required.</p>
</div>
<div class="content"><div class='highlight'><pre> Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
<div class="content"><div class='highlight'><pre> Module = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;module&#x27;</span>
<span class="hljs-function">
<span class="hljs-title">findExtension</span> = <span class="hljs-params">(filename)</span> -&gt;</span>
extensions = path.basename(filename).split <span class="hljs-string">'.'</span></pre></div></div>
extensions = path.basename(filename).split <span class="hljs-string">&#x27;.&#x27;</span></pre></div></div>
</li>
@ -184,14 +184,14 @@ This is a horrible thing that should not be required.</p>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>Remove the initial dot from dotfiles.</p>
</div>
<div class="content"><div class='highlight'><pre> extensions.shift() <span class="hljs-keyword">if</span> extensions[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span></pre></div></div>
<div class="content"><div class='highlight'><pre> extensions.shift() <span class="hljs-keyword">if</span> extensions[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;&#x27;</span></pre></div></div>
</li>
@ -199,23 +199,23 @@ This is a horrible thing that should not be required.</p>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Start with the longest possible extension and work our way shortwards.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">while</span> extensions.shift()
curExtension = <span class="hljs-string">'.'</span> + extensions.join <span class="hljs-string">'.'</span>
curExtension = <span class="hljs-string">&#x27;.&#x27;</span> + extensions.join <span class="hljs-string">&#x27;.&#x27;</span>
<span class="hljs-keyword">return</span> curExtension <span class="hljs-keyword">if</span> Module._extensions[curExtension]
<span class="hljs-string">'.js'</span>
<span class="hljs-string">&#x27;.js&#x27;</span>
Module::load = <span class="hljs-function"><span class="hljs-params">(filename)</span> -&gt;</span>
@filename = filename
@paths = Module._nodeModulePaths path.dirname filename
extension = findExtension filename
Module._extensions[extension](<span class="hljs-keyword">this</span>, filename)
Module._extensions[extension](this, filename)
@loaded = <span class="hljs-literal">true</span></pre></div></div>
</li>
@ -224,8 +224,8 @@ This is a horrible thing that should not be required.</p>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>If were on Node, patch <code>child_process.fork</code> so that Coffee scripts are able
to fork both CoffeeScript files, and JavaScript files, directly.</p>
@ -234,10 +234,10 @@ to fork both CoffeeScript files, and JavaScript files, directly.</p>
<div class="content"><div class='highlight'><pre><span class="hljs-keyword">if</span> child_process
{fork} = child_process
binary = <span class="hljs-built_in">require</span>.resolve <span class="hljs-string">'../../bin/coffee'</span>
binary = <span class="hljs-built_in">require</span>.resolve <span class="hljs-string">&#x27;../../bin/coffee&#x27;</span>
child_process.fork = <span class="hljs-function"><span class="hljs-params">(path, args, options)</span> -&gt;</span>
<span class="hljs-keyword">if</span> helpers.isCoffee path
<span class="hljs-keyword">unless</span> Array.isArray args
<span class="hljs-keyword">unless</span> <span class="hljs-built_in">Array</span>.isArray args
options = args <span class="hljs-keyword">or</span> {}
args = []
args = [path].concat args
@ -250,15 +250,15 @@ to fork both CoffeeScript files, and JavaScript files, directly.</p>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Utility function to find the <code>options</code> object attached to the topmost module.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">getRootModule</span> = <span class="hljs-params">(<span class="hljs-built_in">module</span>)</span> -&gt;</span>
<span class="hljs-keyword">if</span> <span class="hljs-built_in">module</span>.parent <span class="hljs-keyword">then</span> getRootModule <span class="hljs-built_in">module</span>.parent <span class="hljs-keyword">else</span> <span class="hljs-built_in">module</span></pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">getRootModule</span> = <span class="hljs-params">(module)</span> -&gt;</span>
<span class="hljs-keyword">if</span> module.parent <span class="hljs-keyword">then</span> getRootModule module.parent <span class="hljs-keyword">else</span> module</pre></div></div>
</li>

View file

@ -112,27 +112,27 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">'fs'</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">'vm'</span>
nodeREPL = <span class="hljs-built_in">require</span> <span class="hljs-string">'repl'</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">'./'</span>
{merge, updateSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./helpers'</span>
<div class="content"><div class='highlight'><pre>fs = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;fs&#x27;</span>
path = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;path&#x27;</span>
vm = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;vm&#x27;</span>
nodeREPL = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;repl&#x27;</span>
CoffeeScript = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./&#x27;</span>
{merge, updateSyntaxError} = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./helpers&#x27;</span>
sawSIGINT = <span class="hljs-literal">no</span>
transpile = <span class="hljs-literal">no</span>
replDefaults =
prompt: <span class="hljs-string">'coffee&gt; '</span>,
prompt: <span class="hljs-string">&#x27;coffee&gt; &#x27;</span>,
historyFile: <span class="hljs-keyword">do</span> -&gt;
historyPath = process.env.XDG_CACHE_HOME <span class="hljs-keyword">or</span> process.env.HOME
path.join historyPath, <span class="hljs-string">'.coffee_history'</span> <span class="hljs-keyword">if</span> historyPath
path.join historyPath, <span class="hljs-string">&#x27;.coffee_history&#x27;</span> <span class="hljs-keyword">if</span> historyPath
historyMaxInputSize: <span class="hljs-number">10240</span>
eval: <span class="hljs-function"><span class="hljs-params">(input, context, filename, cb)</span> -&gt;</span></pre></div></div>
@ -142,14 +142,14 @@ replDefaults =
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>XXX: multiline hack.</p>
</div>
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/\uFF00/g</span>, <span class="hljs-string">'\n'</span></pre></div></div>
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/\uFF00/g</span>, <span class="hljs-string">&#x27;\n&#x27;</span></pre></div></div>
</li>
@ -157,15 +157,15 @@ replDefaults =
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>Nodes REPL sends the input ending with a newline and then wrapped in
parens. Unwrap all that.</p>
</div>
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/^\(([\s\S]*)\n\)$/m</span>, <span class="hljs-string">'$1'</span></pre></div></div>
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/^\(([\s\S]*)\n\)$/m</span>, <span class="hljs-string">&#x27;$1&#x27;</span></pre></div></div>
</li>
@ -173,15 +173,15 @@ parens. Unwrap all that.</p>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Nodes REPL v6.9.1+ sends the input wrapped in a try/catch statement.
Unwrap that too.</p>
</div>
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/^\s*try\s*{([\s\S]*)}\s*catch.*$/m</span>, <span class="hljs-string">'$1'</span></pre></div></div>
<div class="content"><div class='highlight'><pre> input = input.replace <span class="hljs-regexp">/^\s*try\s*{([\s\S]*)}\s*catch.*$/m</span>, <span class="hljs-string">&#x27;$1&#x27;</span></pre></div></div>
</li>
@ -189,14 +189,14 @@ Unwrap that too.</p>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>Require AST nodes to do some AST manipulation.</p>
</div>
<div class="content"><div class='highlight'><pre> {Block, Assign, Value, Literal, Call, Code, Root} = <span class="hljs-built_in">require</span> <span class="hljs-string">'./nodes'</span>
<div class="content"><div class='highlight'><pre> {Block, Assign, Value, Literal, Call, Code, Root} = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;./nodes&#x27;</span>
<span class="hljs-keyword">try</span></pre></div></div>
@ -206,8 +206,8 @@ Unwrap that too.</p>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Tokenize the clean input.</p>
@ -221,19 +221,19 @@ Unwrap that too.</p>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Filter out tokens generated just to hold comments.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> tokens.length &gt;= <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> tokens[<span class="hljs-number">0</span>].generated <span class="hljs-keyword">and</span>
tokens[<span class="hljs-number">0</span>].comments?.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> <span class="hljs-string">"<span class="hljs-subst">#{tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>]}</span>"</span> <span class="hljs-keyword">is</span> <span class="hljs-string">''</span> <span class="hljs-keyword">and</span>
tokens[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'TERMINATOR'</span>
tokens[<span class="hljs-number">0</span>].comments?.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> <span class="hljs-string">&quot;<span class="hljs-subst">#{tokens[<span class="hljs-number">0</span>][<span class="hljs-number">1</span>]}</span>&quot;</span> <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;&#x27;</span> <span class="hljs-keyword">and</span>
tokens[<span class="hljs-number">1</span>][<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;TERMINATOR&#x27;</span>
tokens = tokens[<span class="hljs-number">2.</span>..]
<span class="hljs-keyword">if</span> tokens.length &gt;= <span class="hljs-number">1</span> <span class="hljs-keyword">and</span> tokens[tokens.length - <span class="hljs-number">1</span>].generated <span class="hljs-keyword">and</span>
tokens[tokens.length - <span class="hljs-number">1</span>].comments?.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> <span class="hljs-string">"<span class="hljs-subst">#{tokens[tokens.length - <span class="hljs-number">1</span>][<span class="hljs-number">1</span>]}</span>"</span> <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
tokens[tokens.length - <span class="hljs-number">1</span>].comments?.length <span class="hljs-keyword">isnt</span> <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> <span class="hljs-string">&quot;<span class="hljs-subst">#{tokens[tokens.length - <span class="hljs-number">1</span>][<span class="hljs-number">1</span>]}</span>&quot;</span> <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;&#x27;</span>
tokens.pop()</pre></div></div>
</li>
@ -242,14 +242,14 @@ Unwrap that too.</p>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Collect referenced variable names just like in <code>CoffeeScript.compile</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> referencedVars = (token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">'IDENTIFIER'</span>)</pre></div></div>
<div class="content"><div class='highlight'><pre> referencedVars = (token[<span class="hljs-number">1</span>] <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> tokens <span class="hljs-keyword">when</span> token[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;IDENTIFIER&#x27;</span>)</pre></div></div>
</li>
@ -257,8 +257,8 @@ Unwrap that too.</p>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p>Generate the AST of the tokens.</p>
@ -272,14 +272,14 @@ Unwrap that too.</p>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>Add assignment to <code>__</code> variable to force the input to be an expression.</p>
</div>
<div class="content"><div class='highlight'><pre> ast = <span class="hljs-keyword">new</span> Block [<span class="hljs-keyword">new</span> Assign (<span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> Literal <span class="hljs-string">'__'</span>), ast, <span class="hljs-string">'='</span>]</pre></div></div>
<div class="content"><div class='highlight'><pre> ast = <span class="hljs-keyword">new</span> Block [<span class="hljs-keyword">new</span> Assign (<span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> Literal <span class="hljs-string">&#x27;__&#x27;</span>), ast, <span class="hljs-string">&#x27;=&#x27;</span>]</pre></div></div>
</li>
@ -287,8 +287,8 @@ Unwrap that too.</p>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>Wrap the expression in a closure to support top-level <code>await</code>.</p>
@ -303,15 +303,15 @@ Unwrap that too.</p>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>Invoke the wrapping closure.</p>
</div>
<div class="content"><div class='highlight'><pre> ast = <span class="hljs-keyword">new</span> Root <span class="hljs-keyword">new</span> Block [<span class="hljs-keyword">new</span> Call ast]
js = ast.compile {bare: <span class="hljs-literal">yes</span>, locals: Object.keys(context), referencedVars, sharedScope: <span class="hljs-literal">yes</span>}
js = ast.compile {bare: <span class="hljs-literal">yes</span>, locals: <span class="hljs-built_in">Object</span>.keys(context), referencedVars, sharedScope: <span class="hljs-literal">yes</span>}
<span class="hljs-keyword">if</span> transpile
js = transpile.transpile(js, transpile.options).code</pre></div></div>
@ -321,15 +321,15 @@ Unwrap that too.</p>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-13">&#x00a7;</a>
</div>
<p>Strip <code>&quot;use strict&quot;</code>, to avoid an exception on assigning to
undeclared variable <code>__</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> js = js.replace <span class="hljs-regexp">/^"use strict"|^'use strict'/</span>, <span class="hljs-string">''</span>
<div class="content"><div class='highlight'><pre> js = js.replace <span class="hljs-regexp">/^&quot;use strict&quot;|^&#x27;use strict&#x27;/</span>, <span class="hljs-string">&#x27;&#x27;</span>
result = runInContext js, context, filename</pre></div></div>
</li>
@ -338,8 +338,8 @@ undeclared variable <code>__</code>.</p>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-14">&#x00a7;</a>
</div>
<p>Await an async result, if necessary.</p>
@ -359,8 +359,8 @@ undeclared variable <code>__</code>.</p>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-15">&#x00a7;</a>
</div>
<p>ASTs <code>compile</code> does not add source code information to syntax errors.</p>
@ -370,7 +370,7 @@ undeclared variable <code>__</code>.</p>
cb err
<span class="hljs-function">
<span class="hljs-title">runInContext</span> = <span class="hljs-params">(js, context, filename)</span> -&gt;</span>
<span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
<span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> global
vm.runInThisContext js, filename
<span class="hljs-keyword">else</span>
vm.runInContext js, context, filename
@ -384,8 +384,8 @@ undeclared variable <code>__</code>.</p>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-16">&#x00a7;</a>
</div>
<p>Node 0.11.12 changed API, prompt is now _prompt.</p>
@ -395,9 +395,9 @@ undeclared variable <code>__</code>.</p>
multiline =
enabled: <span class="hljs-literal">off</span>
initialPrompt: origPrompt.replace <span class="hljs-regexp">/^[^&gt; ]*/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'-'</span>
prompt: origPrompt.replace <span class="hljs-regexp">/^[^&gt; ]*&gt;?/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">'.'</span>
buffer: <span class="hljs-string">''</span></pre></div></div>
initialPrompt: origPrompt.replace <span class="hljs-regexp">/^[^&gt; ]*/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">&#x27;-&#x27;</span>
prompt: origPrompt.replace <span class="hljs-regexp">/^[^&gt; ]*&gt;?/</span>, <span class="hljs-function"><span class="hljs-params">(x)</span> -&gt;</span> x.replace <span class="hljs-regexp">/./g</span>, <span class="hljs-string">&#x27;.&#x27;</span>
buffer: <span class="hljs-string">&#x27;&#x27;</span></pre></div></div>
</li>
@ -405,18 +405,18 @@ undeclared variable <code>__</code>.</p>
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-17">&#x00a7;</a>
</div>
<p>Proxy nodes line listener</p>
</div>
<div class="content"><div class='highlight'><pre> nodeLineListener = repl.listeners(<span class="hljs-string">'line'</span>)[<span class="hljs-number">0</span>]
repl.removeListener <span class="hljs-string">'line'</span>, nodeLineListener
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(cmd)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre> nodeLineListener = repl.listeners(<span class="hljs-string">&#x27;line&#x27;</span>)[<span class="hljs-number">0</span>]
repl.removeListener <span class="hljs-string">&#x27;line&#x27;</span>, nodeLineListener
repl.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;line&#x27;</span>, <span class="hljs-function"><span class="hljs-params">(cmd)</span> -&gt;</span>
<span class="hljs-keyword">if</span> multiline.enabled
multiline.buffer += <span class="hljs-string">"<span class="hljs-subst">#{cmd}</span>\n"</span>
multiline.buffer += <span class="hljs-string">&quot;<span class="hljs-subst">#{cmd}</span>\n&quot;</span>
repl.setPrompt multiline.prompt
repl.prompt <span class="hljs-literal">true</span>
<span class="hljs-keyword">else</span>
@ -430,15 +430,15 @@ undeclared variable <code>__</code>.</p>
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-18">&#x00a7;</a>
</div>
<p>Handle Ctrl-v</p>
</div>
<div class="content"><div class='highlight'><pre> inputStream.<span class="hljs-literal">on</span> <span class="hljs-string">'keypress'</span>, <span class="hljs-function"><span class="hljs-params">(char, key)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> key <span class="hljs-keyword">and</span> key.ctrl <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> key.meta <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> key.shift <span class="hljs-keyword">and</span> key.name <span class="hljs-keyword">is</span> <span class="hljs-string">'v'</span>
<div class="content"><div class='highlight'><pre> inputStream.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;keypress&#x27;</span>, <span class="hljs-function"><span class="hljs-params">(char, key)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">unless</span> key <span class="hljs-keyword">and</span> key.ctrl <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> key.meta <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> key.shift <span class="hljs-keyword">and</span> key.name <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;v&#x27;</span>
<span class="hljs-keyword">if</span> multiline.enabled</pre></div></div>
</li>
@ -447,8 +447,8 @@ undeclared variable <code>__</code>.</p>
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-19">&#x00a7;</a>
</div>
<p>allow arbitrarily switching between modes any time before multiple lines are entered</p>
@ -466,8 +466,8 @@ undeclared variable <code>__</code>.</p>
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-20">&#x00a7;</a>
</div>
<p>no-op unless the current line is empty</p>
@ -481,15 +481,15 @@ undeclared variable <code>__</code>.</p>
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-21">&#x00a7;</a>
</div>
<p>eval, print, loop</p>
</div>
<div class="content"><div class='highlight'><pre> multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
repl.line = <span class="hljs-string">''</span>
repl.line = <span class="hljs-string">&#x27;&#x27;</span>
repl.cursor = <span class="hljs-number">0</span>
repl.output.cursorTo <span class="hljs-number">0</span>
repl.output.clearLine <span class="hljs-number">1</span></pre></div></div>
@ -500,16 +500,16 @@ undeclared variable <code>__</code>.</p>
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-22">&#x00a7;</a>
</div>
<p>XXX: multiline hack</p>
</div>
<div class="content"><div class='highlight'><pre> multiline.buffer = multiline.buffer.replace <span class="hljs-regexp">/\n/g</span>, <span class="hljs-string">'\uFF00'</span>
repl.emit <span class="hljs-string">'line'</span>, multiline.buffer
multiline.buffer = <span class="hljs-string">''</span>
<div class="content"><div class='highlight'><pre> multiline.buffer = multiline.buffer.replace <span class="hljs-regexp">/\n/g</span>, <span class="hljs-string">&#x27;\uFF00&#x27;</span>
repl.emit <span class="hljs-string">&#x27;line&#x27;</span>, multiline.buffer
multiline.buffer = <span class="hljs-string">&#x27;&#x27;</span>
<span class="hljs-keyword">else</span>
multiline.enabled = <span class="hljs-keyword">not</span> multiline.enabled
repl.setPrompt multiline.initialPrompt
@ -522,8 +522,8 @@ undeclared variable <code>__</code>.</p>
<li id="section-23">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-23">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-23">&#x00a7;</a>
</div>
<p>Store and load command history from a file</p>
@ -539,15 +539,15 @@ undeclared variable <code>__</code>.</p>
<li id="section-24">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-24">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-24">&#x00a7;</a>
</div>
<p>Get file info and at most maxSize of command history</p>
</div>
<div class="content"><div class='highlight'><pre> stat = fs.statSync filename
size = Math.min maxSize, stat.size</pre></div></div>
size = <span class="hljs-built_in">Math</span>.min maxSize, stat.size</pre></div></div>
</li>
@ -555,14 +555,14 @@ undeclared variable <code>__</code>.</p>
<li id="section-25">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-25">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-25">&#x00a7;</a>
</div>
<p>Read last <code>size</code> bytes from the file</p>
</div>
<div class="content"><div class='highlight'><pre> readFd = fs.openSync filename, <span class="hljs-string">'r'</span>
<div class="content"><div class='highlight'><pre> readFd = fs.openSync filename, <span class="hljs-string">&#x27;r&#x27;</span>
buffer = Buffer.alloc size
fs.readSync readFd, buffer, <span class="hljs-number">0</span>, size, stat.size - size
fs.closeSync readFd</pre></div></div>
@ -573,14 +573,14 @@ undeclared variable <code>__</code>.</p>
<li id="section-26">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-26">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-26">&#x00a7;</a>
</div>
<p>Set the history on the interpreter</p>
</div>
<div class="content"><div class='highlight'><pre> repl.history = buffer.toString().split(<span class="hljs-string">'\n'</span>).reverse()</pre></div></div>
<div class="content"><div class='highlight'><pre> repl.history = buffer.toString().split(<span class="hljs-string">&#x27;\n&#x27;</span>).reverse()</pre></div></div>
</li>
@ -588,8 +588,8 @@ undeclared variable <code>__</code>.</p>
<li id="section-27">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-27">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-27">&#x00a7;</a>
</div>
<p>If the history file was truncated we should pop off a potential partial line</p>
@ -603,21 +603,21 @@ undeclared variable <code>__</code>.</p>
<li id="section-28">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-28">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-28">&#x00a7;</a>
</div>
<p>Shift off the final blank newline</p>
</div>
<div class="content"><div class='highlight'><pre> repl.history.shift() <span class="hljs-keyword">if</span> repl.history[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">''</span>
<div class="content"><div class='highlight'><pre> repl.history.shift() <span class="hljs-keyword">if</span> repl.history[<span class="hljs-number">0</span>] <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;&#x27;</span>
repl.historyIndex = <span class="hljs-number">-1</span>
lastLine = repl.history[<span class="hljs-number">0</span>]
fd = fs.openSync filename, <span class="hljs-string">'a'</span>
fd = fs.openSync filename, <span class="hljs-string">&#x27;a&#x27;</span>
repl.addListener <span class="hljs-string">'line'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
<span class="hljs-keyword">if</span> code <span class="hljs-keyword">and</span> code.length <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.history'</span> <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'.exit'</span> <span class="hljs-keyword">and</span> lastLine <span class="hljs-keyword">isnt</span> code</pre></div></div>
repl.addListener <span class="hljs-string">&#x27;line&#x27;</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -&gt;</span>
<span class="hljs-keyword">if</span> code <span class="hljs-keyword">and</span> code.length <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">&#x27;.history&#x27;</span> <span class="hljs-keyword">and</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">&#x27;.exit&#x27;</span> <span class="hljs-keyword">and</span> lastLine <span class="hljs-keyword">isnt</span> code</pre></div></div>
</li>
@ -625,14 +625,14 @@ undeclared variable <code>__</code>.</p>
<li id="section-29">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-29">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-29">&#x00a7;</a>
</div>
<p>Save the latest command in the file</p>
</div>
<div class="content"><div class='highlight'><pre> fs.writeSync fd, <span class="hljs-string">"<span class="hljs-subst">#{code}</span>\n"</span>
<div class="content"><div class='highlight'><pre> fs.writeSync fd, <span class="hljs-string">&quot;<span class="hljs-subst">#{code}</span>\n&quot;</span>
lastLine = code</pre></div></div>
</li>
@ -641,15 +641,15 @@ undeclared variable <code>__</code>.</p>
<li id="section-30">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-30">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-30">&#x00a7;</a>
</div>
<p>XXX: The SIGINT event from REPLServer is undocumented, so this is a bit fragile</p>
</div>
<div class="content"><div class='highlight'><pre> repl.<span class="hljs-literal">on</span> <span class="hljs-string">'SIGINT'</span>, <span class="hljs-function">-&gt;</span> sawSIGINT = <span class="hljs-literal">yes</span>
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-&gt;</span> fs.closeSync fd</pre></div></div>
<div class="content"><div class='highlight'><pre> repl.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;SIGINT&#x27;</span>, <span class="hljs-function">-&gt;</span> sawSIGINT = <span class="hljs-literal">yes</span>
repl.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;exit&#x27;</span>, <span class="hljs-function">-&gt;</span> fs.closeSync fd</pre></div></div>
</li>
@ -657,17 +657,17 @@ undeclared variable <code>__</code>.</p>
<li id="section-31">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-31">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-31">&#x00a7;</a>
</div>
<p>Add a command to show the history stack</p>
</div>
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'history'</span>)] =
help: <span class="hljs-string">'Show command history'</span>
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">&#x27;history&#x27;</span>)] =
help: <span class="hljs-string">&#x27;Show command history&#x27;</span>
action: <span class="hljs-function">-&gt;</span>
repl.outputStream.write <span class="hljs-string">"<span class="hljs-subst">#{repl.history[..].reverse().join <span class="hljs-string">'\n'</span>}</span>\n"</span>
repl.outputStream.write <span class="hljs-string">&quot;<span class="hljs-subst">#{repl.history[..].reverse().join <span class="hljs-string">&#x27;\n&#x27;</span>}</span>\n&quot;</span>
repl.displayPrompt()
<span class="hljs-function">
<span class="hljs-title">getCommandId</span> = <span class="hljs-params">(repl, commandName)</span> -&gt;</span></pre></div></div>
@ -678,45 +678,45 @@ undeclared variable <code>__</code>.</p>
<li id="section-32">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-32">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-32">&#x00a7;</a>
</div>
<p>Node 0.11 changed API, a command such as .help is now stored as help</p>
</div>
<div class="content"><div class='highlight'><pre> commandsHaveLeadingDot = repl.commands[<span class="hljs-string">'.help'</span>]?
<span class="hljs-keyword">if</span> commandsHaveLeadingDot <span class="hljs-keyword">then</span> <span class="hljs-string">".<span class="hljs-subst">#{commandName}</span>"</span> <span class="hljs-keyword">else</span> commandName
<div class="content"><div class='highlight'><pre> commandsHaveLeadingDot = repl.commands[<span class="hljs-string">&#x27;.help&#x27;</span>]?
<span class="hljs-keyword">if</span> commandsHaveLeadingDot <span class="hljs-keyword">then</span> <span class="hljs-string">&quot;.<span class="hljs-subst">#{commandName}</span>&quot;</span> <span class="hljs-keyword">else</span> commandName
<span class="hljs-built_in">module</span>.exports =
module.<span class="hljs-built_in">exports</span> =
start: <span class="hljs-function"><span class="hljs-params">(opts = {})</span> -&gt;</span>
[major, minor, build] = process.versions.node.split(<span class="hljs-string">'.'</span>).map (n) -&gt; parseInt(n, <span class="hljs-number">10</span>)
[major, minor, build] = process.versions.node.split(<span class="hljs-string">&#x27;.&#x27;</span>).map (n) -&gt; <span class="hljs-built_in">parseInt</span>(n, <span class="hljs-number">10</span>)
<span class="hljs-keyword">if</span> major &lt; <span class="hljs-number">6</span>
<span class="hljs-built_in">console</span>.warn <span class="hljs-string">"Node 6+ required for CoffeeScript REPL"</span>
console.warn <span class="hljs-string">&quot;Node 6+ required for CoffeeScript REPL&quot;</span>
process.exit <span class="hljs-number">1</span>
CoffeeScript.register()
process.argv = [<span class="hljs-string">'coffee'</span>].concat process.argv[<span class="hljs-number">2.</span>.]
process.argv = [<span class="hljs-string">&#x27;coffee&#x27;</span>].concat process.argv[<span class="hljs-number">2.</span>.]
<span class="hljs-keyword">if</span> opts.transpile
transpile = {}
<span class="hljs-keyword">try</span>
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@babel/core'</span>).transform
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;@babel/core&#x27;</span>).transform
<span class="hljs-keyword">catch</span>
<span class="hljs-keyword">try</span>
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">'babel-core'</span>).transform
transpile.transpile = <span class="hljs-built_in">require</span>(<span class="hljs-string">&#x27;babel-core&#x27;</span>).transform
<span class="hljs-keyword">catch</span>
<span class="hljs-built_in">console</span>.error <span class="hljs-string">'''
console.error <span class="hljs-string">&#x27;&#x27;&#x27;
To use --transpile with an interactive REPL, @babel/core must be installed either in the current folder or globally:
npm install --save-dev @babel/core
or
npm install --global @babel/core
And you must save options to configure Babel in one of the places it looks to find its options.
See https://coffeescript.org/#transpilation
'''</span>
&#x27;&#x27;&#x27;</span>
process.exit <span class="hljs-number">1</span>
transpile.options =
filename: path.resolve process.cwd(), <span class="hljs-string">'&lt;repl&gt;'</span></pre></div></div>
filename: path.resolve process.cwd(), <span class="hljs-string">&#x27;&lt;repl&gt;&#x27;</span></pre></div></div>
</li>
@ -724,8 +724,8 @@ undeclared variable <code>__</code>.</p>
<li id="section-33">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-33">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-33">&#x00a7;</a>
</div>
<p>Since the REPL compilation path is unique (in <code>eval</code> above), we need
another way to get the <code>options</code> object attached to a module so that
@ -734,15 +734,15 @@ the REPL, the only applicable option is <code>transpile</code>.</p>
</div>
<div class="content"><div class='highlight'><pre> Module = <span class="hljs-built_in">require</span> <span class="hljs-string">'module'</span>
<div class="content"><div class='highlight'><pre> Module = <span class="hljs-built_in">require</span> <span class="hljs-string">&#x27;module&#x27;</span>
originalModuleLoad = Module::load
Module::load = <span class="hljs-function"><span class="hljs-params">(filename)</span> -&gt;</span>
@options = transpile: transpile.options
originalModuleLoad.call @, filename
opts = merge replDefaults, opts
repl = nodeREPL.start opts
runInContext opts.prelude, repl.context, <span class="hljs-string">'prelude'</span> <span class="hljs-keyword">if</span> opts.prelude
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-&gt;</span> repl.outputStream.write <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.closed
runInContext opts.prelude, repl.context, <span class="hljs-string">&#x27;prelude&#x27;</span> <span class="hljs-keyword">if</span> opts.prelude
repl.<span class="hljs-literal">on</span> <span class="hljs-string">&#x27;exit&#x27;</span>, <span class="hljs-function">-&gt;</span> repl.outputStream.write <span class="hljs-string">&#x27;\n&#x27;</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.closed
addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile</pre></div></div>
@ -752,14 +752,14 @@ the REPL, the only applicable option is <code>transpile</code>.</p>
<li id="section-34">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-34">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-34">&#x00a7;</a>
</div>
<p>Adapt help inherited from the node REPL</p>
</div>
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">'load'</span>)].help = <span class="hljs-string">'Load code from a file into this REPL session'</span>
<div class="content"><div class='highlight'><pre> repl.commands[getCommandId(repl, <span class="hljs-string">&#x27;load&#x27;</span>)].help = <span class="hljs-string">&#x27;Load code from a file into this REPL session&#x27;</span>
repl</pre></div></div>
</li>

File diff suppressed because it is too large Load diff

View file

@ -112,8 +112,8 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
<p>The <strong>Scope</strong> class regulates lexical scoping within CoffeeScript. As you
generate code, you create a tree of scopes in the same shape as the nested
@ -124,7 +124,7 @@ with external scopes.</p>
</div>
<div class="content"><div class='highlight'><pre>exports.Scope = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Scope</span></span></pre></div></div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.Scope = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Scope</span></span></pre></div></div>
</li>
@ -132,8 +132,8 @@ with external scopes.</p>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the <strong>Block</strong> node it belongs to, which is
@ -145,7 +145,7 @@ that should be output as part of variable declarations.</p>
</div>
<div class="content"><div class='highlight'><pre> constructor: <span class="hljs-function"><span class="hljs-params">(@parent, @expressions, @method, @referencedVars)</span> -&gt;</span>
@variables = [{name: <span class="hljs-string">'arguments'</span>, type: <span class="hljs-string">'arguments'</span>}]
@variables = [{name: <span class="hljs-string">&#x27;arguments&#x27;</span>, type: <span class="hljs-string">&#x27;arguments&#x27;</span>}]
@comments = {}
@positions = {}
@utilities = {} <span class="hljs-keyword">unless</span> @parent</pre></div></div>
@ -156,14 +156,14 @@ that should be output as part of variable declarations.</p>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<p>The <code>@root</code> is the top-level <strong>Scope</strong> object for a given file.</p>
</div>
<div class="content"><div class='highlight'><pre> @root = @parent?.root ? <span class="hljs-keyword">this</span></pre></div></div>
<div class="content"><div class='highlight'><pre> @root = @parent?.root ? this</pre></div></div>
</li>
@ -171,8 +171,8 @@ that should be output as part of variable declarations.</p>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Adds a new variable or overrides an existing one.</p>
@ -191,8 +191,8 @@ that should be output as part of variable declarations.</p>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>When <code>super</code> is called, we need to find the name of the current method were
in, so that we know how to invoke the same method of the parent class. This
@ -212,15 +212,15 @@ function object that has a name filled in, or bottoms out.</p>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Look up a variable name in lexical scope, and declare it if it does not
already exist.</p>
</div>
<div class="content"><div class='highlight'><pre> find: <span class="hljs-function"><span class="hljs-params">(name, type = <span class="hljs-string">'var'</span>)</span> -&gt;</span>
<div class="content"><div class='highlight'><pre> find: <span class="hljs-function"><span class="hljs-params">(name, type = <span class="hljs-string">&#x27;var&#x27;</span>)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> @check name
@add name, type
<span class="hljs-literal">no</span></pre></div></div>
@ -231,8 +231,8 @@ already exist.</p>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<p>Reserve a variable name as originating from a function parameter for this
scope. No <code>var</code> required for internal references.</p>
@ -241,7 +241,7 @@ scope. No <code>var</code> required for internal references.</p>
<div class="content"><div class='highlight'><pre> parameter: <span class="hljs-function"><span class="hljs-params">(name)</span> -&gt;</span>
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> @shared <span class="hljs-keyword">and</span> @parent.check name, <span class="hljs-literal">yes</span>
@add name, <span class="hljs-string">'param'</span></pre></div></div>
@add name, <span class="hljs-string">&#x27;param&#x27;</span></pre></div></div>
</li>
@ -249,8 +249,8 @@ scope. No <code>var</code> required for internal references.</p>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Just check to see if a variable has already been declared, without reserving,
walks up to the root scope.</p>
@ -266,8 +266,8 @@ walks up to the root scope.</p>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p>Generate a temporary variable name at the given index.</p>
@ -276,14 +276,14 @@ walks up to the root scope.</p>
<div class="content"><div class='highlight'><pre> temporary: <span class="hljs-function"><span class="hljs-params">(name, index, single=<span class="hljs-literal">false</span>)</span> -&gt;</span>
<span class="hljs-keyword">if</span> single
startCode = name.charCodeAt(<span class="hljs-number">0</span>)
endCode = <span class="hljs-string">'z'</span>.charCodeAt(<span class="hljs-number">0</span>)
endCode = <span class="hljs-string">&#x27;z&#x27;</span>.charCodeAt(<span class="hljs-number">0</span>)
diff = endCode - startCode
newCode = startCode + index % (diff + <span class="hljs-number">1</span>)
letter = String.fromCharCode(newCode)
letter = <span class="hljs-built_in">String</span>.fromCharCode(newCode)
num = index <span class="hljs-regexp">//</span> (diff + <span class="hljs-number">1</span>)
<span class="hljs-string">"<span class="hljs-subst">#{letter}</span><span class="hljs-subst">#{num <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>}</span>"</span>
<span class="hljs-string">&quot;<span class="hljs-subst">#{letter}</span><span class="hljs-subst">#{num <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;&#x27;</span>}</span>&quot;</span>
<span class="hljs-keyword">else</span>
<span class="hljs-string">"<span class="hljs-subst">#{name}</span><span class="hljs-subst">#{index <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>}</span>"</span></pre></div></div>
<span class="hljs-string">&quot;<span class="hljs-subst">#{name}</span><span class="hljs-subst">#{index <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;&#x27;</span>}</span>&quot;</span></pre></div></div>
</li>
@ -291,8 +291,8 @@ walks up to the root scope.</p>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>Gets the type of a variable.</p>
@ -308,8 +308,8 @@ walks up to the root scope.</p>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>If we need to store an intermediate result, find an available name for a
compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on…</p>
@ -322,7 +322,7 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on…
temp = @temporary name, index, options.single
<span class="hljs-keyword">break</span> <span class="hljs-keyword">unless</span> @check(temp) <span class="hljs-keyword">or</span> temp <span class="hljs-keyword">in</span> @root.referencedVars
index++
@add temp, <span class="hljs-string">'var'</span>, <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> options.reserve ? <span class="hljs-literal">true</span>
@add temp, <span class="hljs-string">&#x27;var&#x27;</span>, <span class="hljs-literal">yes</span> <span class="hljs-keyword">if</span> options.reserve ? <span class="hljs-literal">true</span>
temp</pre></div></div>
</li>
@ -331,8 +331,8 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on…
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>Ensure that an assignment is made at the top of this scope
(or at the top-level scope, if requested).</p>
@ -349,8 +349,8 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on…
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-13">&#x00a7;</a>
</div>
<p>Does this scope have any declared variables?</p>
@ -365,15 +365,15 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on…
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-14">&#x00a7;</a>
</div>
<p>Return the list of variables first declared in this scope.</p>
</div>
<div class="content"><div class='highlight'><pre> declaredVariables: <span class="hljs-function">-&gt;</span>
(v.name <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.type <span class="hljs-keyword">is</span> <span class="hljs-string">'var'</span>).sort()</pre></div></div>
(v.name <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.type <span class="hljs-keyword">is</span> <span class="hljs-string">&#x27;var&#x27;</span>).sort()</pre></div></div>
</li>
@ -381,8 +381,8 @@ compiler-generated variable. <code>_var</code>, <code>_var2</code>, and so on…
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-15">&#x00a7;</a>
</div>
<p>Return the list of assignments that are supposed to be made at the top
of this scope.</p>
@ -390,7 +390,7 @@ of this scope.</p>
</div>
<div class="content"><div class='highlight'><pre> assignedVariables: <span class="hljs-function">-&gt;</span>
<span class="hljs-string">"<span class="hljs-subst">#{v.name}</span> = <span class="hljs-subst">#{v.type.value}</span>"</span> <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.type.assigned</pre></div></div>
<span class="hljs-string">&quot;<span class="hljs-subst">#{v.name}</span> = <span class="hljs-subst">#{v.type.value}</span>&quot;</span> <span class="hljs-keyword">for</span> v <span class="hljs-keyword">in</span> @variables <span class="hljs-keyword">when</span> v.type.assigned</pre></div></div>
</li>

View file

@ -112,8 +112,8 @@
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-1">&#x00a7;</a>
</div>
<p>Source maps allow JavaScript runtimes to match running JavaScript back to
the original source code that corresponds to it. This can be minified
@ -134,8 +134,8 @@ of this information — to write out alongside the generated JavaScript.</p>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-2">&#x00a7;</a>
</div>
<p>A <strong>LineMap</strong> object keeps track of information about original line and column
positions for a single line of output JavaScript code.
@ -161,8 +161,8 @@ positions for a single line of output JavaScript code.
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-3">&#x00a7;</a>
</div>
<h2 id="sourcemap">SourceMap</h2>
@ -174,8 +174,8 @@ positions for a single line of output JavaScript code.
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-4">&#x00a7;</a>
</div>
<p>Maps locations in a single generated JavaScript file back to locations in
the original CoffeeScript source file.</p>
@ -195,8 +195,8 @@ through the arrays of line and column buffer to produce it.</p>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-5">&#x00a7;</a>
</div>
<p>Adds a mapping to this SourceMap. <code>sourceLocation</code> and <code>generatedLocation</code>
are both <code>[line, column]</code> arrays. If <code>options.noReplace</code> is true, then if there
@ -216,8 +216,8 @@ effect.</p>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-6">&#x00a7;</a>
</div>
<p>Look up the original position of a given <code>line</code> and <code>column</code> in the generated
code.</p>
@ -234,8 +234,8 @@ code.</p>
<li id="section-7">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-7">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-7">&#x00a7;</a>
</div>
<h2 id="v3-sourcemap-generation">V3 SourceMap Generation</h2>
@ -247,8 +247,8 @@ code.</p>
<li id="section-8">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-8">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-8">&#x00a7;</a>
</div>
<p>Builds up a V3 source map, returning the generated JSON as a string.
<code>options.sourceRoot</code> may be used to specify the sourceRoot written to the source
@ -263,14 +263,14 @@ set “sources” and “file”, respectively.</p>
lastSourceLine = <span class="hljs-number">0</span>
lastSourceColumn = <span class="hljs-number">0</span>
needComma = <span class="hljs-literal">no</span>
buffer = <span class="hljs-string">""</span>
buffer = <span class="hljs-string">&quot;&quot;</span>
<span class="hljs-keyword">for</span> lineMap, lineNumber <span class="hljs-keyword">in</span> @lines <span class="hljs-keyword">when</span> lineMap
<span class="hljs-keyword">for</span> mapping <span class="hljs-keyword">in</span> lineMap.columns <span class="hljs-keyword">when</span> mapping
<span class="hljs-keyword">while</span> writingline &lt; mapping.line
lastColumn = <span class="hljs-number">0</span>
needComma = <span class="hljs-literal">no</span>
buffer += <span class="hljs-string">";"</span>
buffer += <span class="hljs-string">&quot;;&quot;</span>
writingline++</pre></div></div>
</li>
@ -279,15 +279,15 @@ set “sources” and “file”, respectively.</p>
<li id="section-9">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-9">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-9">&#x00a7;</a>
</div>
<p>Write a comma if weve already written a segment on this line.</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> needComma
buffer += <span class="hljs-string">","</span>
buffer += <span class="hljs-string">&quot;,&quot;</span>
needComma = <span class="hljs-literal">no</span></pre></div></div>
</li>
@ -296,8 +296,8 @@ set “sources” and “file”, respectively.</p>
<li id="section-10">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-10">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-10">&#x00a7;</a>
</div>
<p>Write the next segment. Segments can be 1, 4, or 5 values. If just one, then it
is a generated column which doesnt match anything in the source code.</p>
@ -315,8 +315,8 @@ column for the current line:</p>
<li id="section-11">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-11">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-11">&#x00a7;</a>
</div>
<p>The index into the list of sources:</p>
@ -330,8 +330,8 @@ column for the current line:</p>
<li id="section-12">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-12">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-12">&#x00a7;</a>
</div>
<p>The starting line in the original source, relative to the previous source line.</p>
@ -346,8 +346,8 @@ column for the current line:</p>
<li id="section-13">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-13">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-13">&#x00a7;</a>
</div>
<p>The starting column in the original source, relative to the previous column.</p>
@ -363,8 +363,8 @@ column for the current line:</p>
<li id="section-14">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-14">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-14">&#x00a7;</a>
</div>
<p>Produce the canonical JSON object format for a “v3” source map.</p>
@ -375,12 +375,12 @@ column for the current line:</p>
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> options.filename
[options.filename]
<span class="hljs-keyword">else</span>
[<span class="hljs-string">'&lt;anonymous&gt;'</span>]
[<span class="hljs-string">&#x27;&lt;anonymous&gt;&#x27;</span>]
v3 =
version: <span class="hljs-number">3</span>
file: options.generatedFile <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>
sourceRoot: options.sourceRoot <span class="hljs-keyword">or</span> <span class="hljs-string">''</span>
file: options.generatedFile <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;&#x27;</span>
sourceRoot: options.sourceRoot <span class="hljs-keyword">or</span> <span class="hljs-string">&#x27;&#x27;</span>
sources: sources
names: []
mappings: buffer
@ -395,8 +395,8 @@ column for the current line:</p>
<li id="section-15">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-15">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-15">&#x00a7;</a>
</div>
<h2 id="base64-vlq-encoding">Base64 VLQ Encoding</h2>
@ -408,8 +408,8 @@ column for the current line:</p>
<li id="section-16">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-16">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-16">&#x00a7;</a>
</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
@ -424,7 +424,7 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - <span class="hljs-number">1</span> <span class="hljs-comment"># 0001 1111</span>
encodeVlq: <span class="hljs-function"><span class="hljs-params">(value)</span> -&gt;</span>
answer = <span class="hljs-string">''</span></pre></div></div>
answer = <span class="hljs-string">&#x27;&#x27;</span></pre></div></div>
</li>
@ -432,8 +432,8 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
<li id="section-17">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-17">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-17">&#x00a7;</a>
</div>
<p>Least significant bit represents the sign.</p>
@ -447,14 +447,14 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
<li id="section-18">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-18">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-18">&#x00a7;</a>
</div>
<p>The next bits are the actual value.</p>
</div>
<div class="content"><div class='highlight'><pre> valueToEncode = (Math.abs(value) &lt;&lt; <span class="hljs-number">1</span>) + signBit</pre></div></div>
<div class="content"><div class='highlight'><pre> valueToEncode = (<span class="hljs-built_in">Math</span>.abs(value) &lt;&lt; <span class="hljs-number">1</span>) + signBit</pre></div></div>
</li>
@ -462,8 +462,8 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
<li id="section-19">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-19">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-19">&#x00a7;</a>
</div>
<p>Make sure we encode at least one character, even if valueToEncode is 0.</p>
@ -483,8 +483,8 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
<li id="section-20">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-20">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-20">&#x00a7;</a>
</div>
<h2 id="regular-base64-encoding">Regular Base64 Encoding</h2>
@ -496,16 +496,16 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
<li id="section-21">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-21">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-21">&#x00a7;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre> BASE64_CHARS = <span class="hljs-string">'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'</span>
<div class="content"><div class='highlight'><pre> BASE64_CHARS = <span class="hljs-string">&#x27;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/&#x27;</span>
encodeBase64: <span class="hljs-function"><span class="hljs-params">(value)</span> -&gt;</span>
BASE64_CHARS[value] <span class="hljs-keyword">or</span> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Cannot Base64 encode value: <span class="hljs-subst">#{value}</span>"</span></pre></div></div>
BASE64_CHARS[value] <span class="hljs-keyword">or</span> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span> <span class="hljs-string">&quot;Cannot Base64 encode value: <span class="hljs-subst">#{value}</span>&quot;</span></pre></div></div>
</li>
@ -513,14 +513,14 @@ bits of the original value encoded into the first byte of the VLQ encoded value.
<li id="section-22">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-22">&#182;</a>
<div class="sswrap ">
<a class="ss" href="#section-22">&#x00a7;</a>
</div>
<p>Our API for source maps is just the <code>SourceMap</code> class.</p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">module</span>.exports = SourceMap</pre></div></div>
<div class="content"><div class='highlight'><pre>module.<span class="hljs-built_in">exports</span> = SourceMap</pre></div></div>
</li>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -16,7 +16,7 @@
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<!-- The CoffeeScript logo font is Googles Galada -->
<link href="https://fonts.googleapis.com/css?family=Alegreya+Sans:400,800|Lato:300,300i,400,700|Roboto+Mono:400,400i" rel="stylesheet" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/codemirror@5.37.0/lib/codemirror.css" rel="stylesheet" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/codemirror@5.62.3/lib/codemirror.css" rel="stylesheet" crossorigin="anonymous">
<style>
/* Adapted from https://github.com/FarhadG/code-mirror-themes/blob/master/themes/twilight.css and https://github.com/codemirror/CodeMirror/blob/master/theme/twilight.css */
@ -694,7 +694,7 @@ textarea {
<section id="introduction">
<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="https://github.com/jashkenas/coffeescript/tarball/2.5.1">2.5.1</a></p>
<p><strong>Latest Version:</strong> <a href="https://github.com/jashkenas/coffeescript/tarball/2.6.0">2.6.0</a></p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash"><span class="comment"># Install locally for a project:</span>
npm install --save-dev coffeescript
@ -897,10 +897,11 @@ cubes = (function() {
<h3>Compatibility</h3>
<p>Most modern JavaScript features that CoffeeScript supports can run natively in Node 7.6+, meaning that Node can run CoffeeScripts output without any further processing required. Here are some notable exceptions:</p>
<ul>
<li><a href="#modules">Modules</a> and <a href="#jsx">JSX</a> always require transpilation.</li>
<li><a href="#jsx">JSX</a> always requires transpilation.</li>
<li><a href="https://coffeescript.org/#splats">Splats, a.k.a. object rest/spread syntax, for objects</a> are supported by Node 8.6+.</li>
<li>The <a href="https://github.com/tc39/proposal-regexp-dotall-flag">regular expression <code>s</code> (dotall) flag</a> is supported by Node 9+.</li>
<li><a href="https://github.com/tc39/proposal-async-iteration">Async generator functions</a> are supported by Node 10+.</li>
<li><a href="#modules">Modules</a> are supported by Node 12+ with <code>&quot;type&quot;: &quot;module&quot;</code> in your projects <code>package.json</code>.</li>
</ul>
<p>This list may be incomplete, and excludes versions of Node that support newer features behind flags; please refer to <a href="http://node.green/">node.green</a> for full details. You can <a href="test.html">run the tests in your browser</a> to see what your browser supports. It is your responsibility to ensure that your runtime supports the modern features you use; or that you <a href="#transpilation">transpile</a> your code. When in doubt, transpile.</p>
@ -1029,14 +1030,14 @@ cubes = (function() {
<section id="nodejs-usage">
<h3>Node.js</h3>
<p>If youd like to use Node.js CommonJS to <code>require</code> CoffeeScript files, e.g. <code>require './app.coffee'</code>, you must first “register” CoffeeScript as an extension:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="built_in">require</span> <span class="string">'coffeescript/register'</span>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="built_in">require</span> <span class="string">&#x27;coffeescript/register&#x27;</span>
App = <span class="built_in">require</span> <span class="string">'./app'</span> <span class="comment"># The .coffee extension is optional</span>
App = <span class="built_in">require</span> <span class="string">&#x27;./app&#x27;</span> <span class="comment"># The .coffee extension is optional</span>
</code></pre>
</blockquote><p>If you want to use the compilers API, for example to make an app that compiles strings of CoffeeScript on the fly, you can <code>require</code> the full module:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee">CoffeeScript = <span class="built_in">require</span> <span class="string">'coffeescript'</span>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee">CoffeeScript = <span class="built_in">require</span> <span class="string">&#x27;coffeescript&#x27;</span>
eval CoffeeScript.compile <span class="string">'console.log "Mmmmm, I could really go for some #{Math.pi}"'</span>
<span class="built_in">eval</span> CoffeeScript.compile <span class="string">&#x27;console.log &quot;Mmmmm, I could really go for some #{Math.pi}&quot;&#x27;</span>
</code></pre>
</blockquote><p>The <code>compile</code> method has the signature <code>compile(code, options)</code> where <code>code</code> is a string of CoffeeScript code, and the optional <code>options</code> is an object with some or all of the following properties:</p>
<ul>
@ -1056,7 +1057,7 @@ eval CoffeeScript.compile <span class="string">'console.log "Mmmmm, I could real
<h4>Quickstart</h4>
<p>From the root of your project:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">npm install --save-dev @babel/core @babel/preset-env
<span class="built_in">echo</span> <span class="string">'{ "presets": ["@babel/env"] }'</span> &gt; .babelrc
<span class="built_in">echo</span> <span class="string">&#x27;{ &quot;presets&quot;: [&quot;@babel/env&quot;] }&#x27;</span> &gt; .babelrc
coffee --compile --transpile --inline-map some-file.coffee
</code></pre>
</blockquote><h4>Transpiling with the CoffeeScript compiler</h4>
@ -1072,7 +1073,7 @@ coffee --compile --transpile --inline-map some-file.coffee
</blockquote><p>See <a href="https://babeljs.io/docs/plugins/">Babels website to learn about presets and plugins</a> and the multitude of options you have. Another preset you might need is <a href="https://babeljs.io/docs/en/babel-plugin-transform-react-jsx/"><code>@babel/plugin-transform-react-jsx</code></a> if youre using JSX with React (JSX can also be used with other frameworks).</p>
<p>Once you have <code>@babel/core</code> and <code>@babel/preset-env</code> (or other presets or plugins) installed, and a <code>.babelrc</code> file (or other equivalent) in place, you can use <code>coffee --transpile</code> to pipe CoffeeScripts output through Babel using the options youve saved.</p>
<p>If youre using CoffeeScript via the <a href="nodejs_usage">Node API</a>, where you call <code>CoffeeScript.compile</code> with a string to be compiled and an <code>options</code> object, the <code>transpile</code> key of the <code>options</code> object should be the Babel options:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-js">CoffeeScript.compile(code, {<span class="attr">transpile</span>: {<span class="attr">presets</span>: [<span class="string">'@babel/env'</span>]}})
<blockquote class="uneditable-code-block"><pre><code class="language-js"><span class="title class_">CoffeeScript</span>.<span class="title function_">compile</span>(code, {<span class="attr">transpile</span>: {<span class="attr">presets</span>: [<span class="string">&#x27;@babel/env&#x27;</span>]}})
</code></pre>
</blockquote><p>You can also transpile CoffeeScripts output without using the <code>transpile</code> option, for example as part of a build chain. This lets you use transpilers other than Babel, and it gives you greater control over the process. There are many great task runners for setting up JavaScript build chains, such as <a href="http://gulpjs.com/">Gulp</a>, <a href="https://webpack.github.io/">Webpack</a>, <a href="https://gruntjs.com/">Grunt</a> and <a href="http://broccolijs.com/">Broccoli</a>.</p>
<h4>Polyfills</h4>
@ -4242,12 +4243,12 @@ greet = function(name, adjective) {
</section>
<section id="modules">
<h2>Modules</h2>
<p>ES2015 modules are supported in CoffeeScript, with very similar <code>import</code> and <code>export</code> syntax:</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules">ES2015 modules</a> are supported in CoffeeScript, with very similar <code>import</code> and <code>export</code> syntax:</p>
<aside class="code-example container-fluid bg-ribbed-dark" data-example="modules">
<div class="row">
<div class="col-md-6 coffeescript-input-column">
<textarea class="coffeescript-input" id="modules-coffee">import './local-file.coffee'
import 'coffeescript'
<textarea class="coffeescript-input" id="modules-coffee">import './local-file.js' # Must be the filename of the generated file
import 'package'
import _ from 'underscore'
import * as underscore from 'underscore'
@ -4269,8 +4270,8 @@ export { Mathematics as default, sqrt as squareRoot }
export * from 'underscore'
export { max, min } from 'underscore'
</textarea>
<pre class="placeholder-code"><span class="cm-variable">import</span> <span class="cm-string">'./local-file.coffee'</span>
<span class="cm-variable">import</span> <span class="cm-string">'coffeescript'</span>
<pre class="placeholder-code"><span class="cm-variable">import</span> <span class="cm-string">'./local-file.js'</span> <span class="cm-comment"># Must be the filename of the generated file</span>
<span class="cm-variable">import</span> <span class="cm-string">'package'</span>
<span class="cm-variable">import</span> <span class="cm-variable">_</span> <span class="cm-variable">from</span> <span class="cm-string">'underscore'</span>
<span class="cm-variable">import</span> <span class="cm-operator">*</span> <span class="cm-variable">as</span> <span class="cm-variable">underscore</span> <span class="cm-variable">from</span> <span class="cm-string">'underscore'</span>
@ -4294,9 +4295,9 @@ export { max, min } from 'underscore'
</pre>
</div>
<div class="col-md-6 javascript-output-column">
<textarea class="javascript-output" id="modules-js">import './local-file.coffee';
<textarea class="javascript-output" id="modules-js">import './local-file.js';
import 'coffeescript';
import 'package';
import _ from 'underscore';
@ -4356,9 +4357,9 @@ export {
min
} from 'underscore';
</textarea>
<pre class="placeholder-code"><span class="cm-keyword">import</span> <span class="cm-string">'./local-file.coffee'</span>;
<pre class="placeholder-code"><span class="cm-keyword">import</span> <span class="cm-string">'./local-file.js'</span>;
<span class="cm-keyword">import</span> <span class="cm-string">'coffeescript'</span>;
<span class="cm-keyword">import</span> <span class="cm-string">'package'</span>;
<span class="cm-keyword">import</span> <span class="cm-def">_</span> <span class="cm-keyword">from</span> <span class="cm-string">'underscore'</span>;
@ -4485,8 +4486,8 @@ else
</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 to <a href="#transpilation">transpile</a> 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>
<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. Such statements can be run by all modern browsers (when the script is referenced via <code>&lt;script type=&quot;module&quot;&gt;</code>) and <a href="https://nodejs.org/api/esm.html#esm_enabling">by Node.js</a> when the output <code>.js</code> files are in a folder where the nearest parent <code>package.json</code> file contains <code>&quot;type&quot;: &quot;module&quot;</code>. Because the runtime is evaluating the generated output, the <code>import</code> statements must reference the output files; so if <code>file.coffee</code> is output as <code>file.js</code>, it needs to be referenced as <code>file.js</code> in the <code>import</code> statement, with the <code>.js</code> extension included.</p>
<p>Also, 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>
</section>
<section id="embedded">
@ -4921,7 +4922,7 @@ The CoffeeScript logo is available in SVG for use in presentations.</li>
</section>
<section id="annotated-source">
<h2>Annotated Source</h2>
<p>You can browse the CoffeeScript 2.5.1 source in readable, annotated form <a href="annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
<p>You can browse the CoffeeScript 2.6.0 source in readable, annotated form <a href="annotated-source/">here</a>. You can also jump directly to a particular source file:</p>
<ul>
<li><a href="annotated-source/grammar.html">Grammar Rules — src/grammar</a></li>
<li><a href="annotated-source/lexer.html">Lexing Tokens — src/lexer</a></li>
@ -4963,8 +4964,8 @@ The CoffeeScript logo is available in SVG for use in presentations.</li>
<p>When CoffeeScript was designed, <code>var</code> was <a href="https://github.com/jashkenas/coffeescript/issues/238#issuecomment-153502">intentionally omitted</a>. This was to spare developers the mental housekeeping of needing to worry about variable <em>declaration</em> (<code>var foo</code>) as opposed to variable <em>assignment</em> (<code>foo = 1</code>). The CoffeeScript compiler automatically takes care of declaration for you, by generating <code>var</code> statements at the top of every function scope. This makes it impossible to accidentally declare a global variable.</p>
<p><code>let</code> and <code>const</code> add a useful ability to JavaScript in that you can use them to declare variables within a <em>block</em> scope, for example within an <code>if</code> statement body or a <code>for</code> loop body, whereas <code>var</code> always declares variables in the scope of an entire function. When CoffeeScript 2 was designed, there was much discussion of whether this functionality was useful enough to outweigh the simplicity offered by never needing to consider variable declaration in CoffeeScript. In the end, it was decided that the simplicity was more valued. In CoffeeScript there remains only one type of variable.</p>
<p>Keep in mind that <code>const</code> only protects you from <em>reassigning</em> a variable; it doesnt prevent the variables value from changing, the way constants usually do in other languages:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-js"><span class="keyword">const</span> obj = {<span class="attr">foo</span>: <span class="string">'bar'</span>};
obj.foo = <span class="string">'baz'</span>; <span class="comment">// Allowed!</span>
<blockquote class="uneditable-code-block"><pre><code class="language-js"><span class="keyword">const</span> obj = {<span class="attr">foo</span>: <span class="string">&#x27;bar&#x27;</span>};
obj.<span class="property">foo</span> = <span class="string">&#x27;baz&#x27;</span>; <span class="comment">// Allowed!</span>
obj = {}; <span class="comment">// Throws error</span>
</code></pre>
</blockquote>
@ -5207,7 +5208,7 @@ a; // Equals 1 in CoffeeScript 1.x, null in CoffeeScript 2
<section id="breaking-changes-bound-generator-functions">
<h3>Bound generator functions</h3>
<p>Bound generator functions, a.k.a. generator arrow functions, <a href="http://stackoverflow.com/questions/27661306/can-i-use-es6s-arrow-function-syntax-with-generators-arrow-notation">arent allowed in ECMAScript</a>. You can write <code>function*</code> or <code>=&gt;</code>, but not both. Therefore, CoffeeScript code like this:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="function"><span class="title">f</span> = =&gt;</span> <span class="keyword">yield</span> <span class="keyword">this</span>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="function"><span class="title">f</span> = =&gt;</span> <span class="keyword">yield</span> this
<span class="comment"># Throws a compiler error</span>
</code></pre>
</blockquote><p>Needs to be rewritten the old-fashioned way:</p>
@ -5260,7 +5261,7 @@ f = function*() {
<span class="class"><span class="keyword">class</span> <span class="title">Component</span> <span class="keyword">extends</span> <span class="title">Base</span></span>
onClick: <span class="function">=&gt;</span>
<span class="built_in">console</span>.log <span class="string">'Clicked!'</span>, @
console.log <span class="string">&#x27;Clicked!&#x27;</span>, @
</code></pre>
</blockquote><p>Class methods cant be used with <code>new</code> (uncommon):</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">Namespace</span></span>
@ -5269,8 +5270,8 @@ f = function*() {
</code></pre>
</blockquote><p>Due to the hoisting required to compile to ES2015 classes, dynamic keys in class methods cant use values from the executable class body unless the methods are assigned in prototype style.</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">A</span></span>
name = <span class="string">'method'</span>
<span class="string">"<span class="subst">#{name}</span>"</span>: <span class="function">-&gt;</span> <span class="comment"># This method will be named 'undefined'</span>
name = <span class="string">&#x27;method&#x27;</span>
<span class="string">&quot;<span class="subst">#{name}</span>&quot;</span>: <span class="function">-&gt;</span> <span class="comment"># This method will be named &#x27;undefined&#x27;</span>
@::[name] = <span class="function">-&gt;</span> <span class="comment"># This will work; assigns to `A.prototype.method`</span>
</code></pre>
</blockquote>
@ -5279,12 +5280,12 @@ f = function*() {
<h3><code>super</code> and <code>this</code></h3>
<p>In the constructor of a derived class (a class that <code>extends</code> another class), <code>this</code> cannot be used before calling <code>super</code>:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">B</span> <span class="keyword">extends</span> <span class="title">A</span></span>
constructor: <span class="function">-&gt;</span> <span class="keyword">this</span> <span class="comment"># Throws a compiler error</span>
constructor: <span class="function">-&gt;</span> this <span class="comment"># Throws a compiler error</span>
</code></pre>
</blockquote><p>This also means you cannot pass a reference to <code>this</code> as an argument to <code>super</code> in the constructor of a derived class:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">B</span> <span class="keyword">extends</span> <span class="title">A</span></span>
constructor: <span class="function"><span class="params">(@arg)</span> -&gt;</span>
<span class="keyword">super</span> @arg <span class="comment"># Throws a compiler error</span>
super @arg <span class="comment"># Throws a compiler error</span>
</code></pre>
</blockquote><p>This is a limitation of ES2015 classes. As a workaround, assign to <code>this</code> after the <code>super</code> call:</p>
<aside class="code-example container-fluid bg-ribbed-dark" data-example="breaking_change_super_this">
@ -5332,7 +5333,7 @@ B = class B extends A {
<h3><code>super</code> and <code>extends</code></h3>
<p>Due to a syntax clash with <code>super</code> with accessors, “bare” <code>super</code> (the keyword <code>super</code> without parentheses) no longer compiles to a super call forwarding all arguments.</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="class"><span class="keyword">class</span> <span class="title">B</span> <span class="keyword">extends</span> <span class="title">A</span></span>
foo: <span class="function">-&gt;</span> <span class="keyword">super</span>
foo: <span class="function">-&gt;</span> super
<span class="comment"># Throws a compiler error</span>
</code></pre>
</blockquote><p>Arguments can be forwarded explicitly using splats:</p>
@ -5406,8 +5407,8 @@ B = class B extends A {
<p>CoffeeScript 1.x allowed the <code>extends</code> keyword to set up prototypal inheritance between functions, and <code>super</code> could be used manually prototype-assigned functions:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="function"><span class="title">A</span> = -&gt;</span>
<span class="function"><span class="title">B</span> = -&gt;</span>
B extends A
B.prototype.foo = <span class="function">-&gt;</span> <span class="keyword">super</span> arguments...
B <span class="keyword">extends</span> A
B.prototype.foo = <span class="function">-&gt;</span> super arguments...
<span class="comment"># Last two lines each throw compiler errors in CoffeeScript 2</span>
</code></pre>
</blockquote><p>Due to the switch to ES2015 <code>extends</code> and <code>super</code>, using these keywords for prototypal functions are no longer supported. The above case could be refactored to:</p>
@ -5585,7 +5586,7 @@ B = class B extends A {
<blockquote class="uneditable-code-block"><pre><code class="language-coffee"><span class="comment">#!/usr/bin/env coffee</span>
x = <span class="number">2</span> + <span class="number">2</span>
<span class="built_in">console</span>.log x
console.log x
</code></pre>
</blockquote><p>If this were saved as <code>executable.coffee</code>, it could be made executable and run:</p>
<blockquote class="uneditable-code-block"><pre><code class="language-bash">▶ chmod +x ./executable.coffee
@ -5599,6 +5600,16 @@ x = <span class="number">2</span> + <span class="number">2</span>
<section id="changelog">
<h2>Changelog</h2>
<section id="2.6.0">
<h3><a href="https://github.com/jashkenas/coffeescript/compare/2.5.1...2.6.0">2.6.0</a>
<span class="timestamp"> &mdash; <time datetime="2021-09-19">2021-09-19</time></span>
</h3><ul>
<li>The syntax <code>import.meta</code>, including <code>import.meta.url</code>, is now supported.</li>
<li>The <code>await</code> keyword is now supported outside of functions (in other words, at the top level). <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await">Note that JavaScript runtimes only support this for ES modules.</a></li>
<li>Bugfix for a <code>for</code> comprehension at the end of an <code>unless</code> or <code>until</code> line.</li>
</ul>
</section>
<section id="2.5.1">
<h3><a href="https://github.com/jashkenas/coffeescript/compare/2.5.0...2.5.1">2.5.1</a>
<span class="timestamp"> &mdash; <time datetime="2020-01-31">2020-01-31</time></span>

View file

@ -4280,7 +4280,7 @@ test "AST as expected for If node", ->
inverted: no
]
test "AST as expected for MetaProperty node", ->
test "AST as expected for `new.target` MetaProperty node", ->
testExpression '''
-> new.target
''',
@ -4313,6 +4313,25 @@ test "AST as expected for MetaProperty node", ->
computed: no
]
test "AST as expected for `import.meta` MetaProperty node", ->
testExpression '''
import.meta
''',
type: 'MetaProperty'
meta: ID 'import'
property: ID 'meta'
testExpression '''
import.meta.name
''',
type: 'MemberExpression'
object:
type: 'MetaProperty'
meta: ID 'import'
property: ID 'meta'
property: ID 'name'
computed: no
test "AST as expected for dynamic import", ->
testExpression '''
import('a')
@ -10770,7 +10789,7 @@ test "AST as expected for While node", ->
line: 3
column: 5
test "AST location data as expected for MetaProperty node", ->
test "AST location data as expected for `new.target` MetaProperty node", ->
testAstLocationData '''
-> new.target
''',
@ -10822,6 +10841,44 @@ test "AST location data as expected for MetaProperty node", ->
line: 1
column: 13
test "AST location data as expected for `import.meta` MetaProperty node", ->
testAstLocationData '''
import.meta
''',
type: 'MetaProperty'
meta:
start: 0
end: 6
range: [0, 6]
loc:
start:
line: 1
column: 0
end:
line: 1
column: 6
property:
start: 7
end: 11
range: [7, 11]
loc:
start:
line: 1
column: 7
end:
line: 1
column: 11
start: 0
end: 11
range: [0, 11]
loc:
start:
line: 1
column: 0
end:
line: 1
column: 11
test "AST location data as expected for For node", ->
testAstLocationData 'for x, i in arr when x? then return',
type: 'For'
@ -15649,6 +15706,20 @@ test "#3199: await multiline implicit object", ->
msg: 'b'
eq undefined, y
test "top-level await", ->
eqJS 'await null', 'await null;'
test "top-level wrapper has correct async attribute", ->
starts = (code, prefix) ->
compiled = CoffeeScript.compile code
unless compiled.startsWith prefix
fail """Expected generated JavaScript to start with:
#{reset}#{prefix}#{red}
but instead it was:
#{reset}#{compiled}#{red}"""
starts 'await null', '(async function'
starts 'do -> await null', '(function'
</script>
<script type="text/x-coffeescript" class="test" id="async_iterators">
# This is always fulfilled.
@ -17629,6 +17700,10 @@ test "#4609: Support new.target", ->
new Foo()
eq newTarget, yes
test "#5323: new.target can be the argument of a function", ->
fn = (arg) -> arg
fn new.target
test "#5085: Bug: @ reference to class not maintained in do block", ->
thisFoo = 'initial foo'
thisBar = 'initial bar'
@ -19611,6 +19686,11 @@ test "for pattern variables can linebreak/indent", ->
] in listOfArrays
eq a, 2
test "#5309: comprehension as postfix condition", ->
doesNotThrowCompileError """
throw new Error "DOOM was called with a null element" unless elm? for elm in elms
"""
</script>
<script type="text/x-coffeescript" class="test" id="control_flow">
# Control Flow
@ -22186,14 +22266,7 @@ test "CoffeeScript keywords cannot be used as local names in import list aliases
^^^^^^
'''
test "cannot have `await` outside a function", ->
assertErrorFormat '''
await 1
''', '''
[stdin]:1:1: error: await can only occur inside functions
await 1
^^^^^^^
'''
test "cannot have `await return` outside a function", ->
assertErrorFormat '''
await return
''', '''
@ -22896,6 +22969,15 @@ test "`new.target` is only allowed meta property", ->
^^^^^^^^^^^^^
'''
test "`import.meta` is only allowed meta property", ->
assertErrorFormat '''
foo = import.something
''', '''
[stdin]:1:7: error: the only valid meta property for import is import.meta
foo = import.something
^^^^^^^^^^^^^^^^
'''
test "`new.target` cannot be assigned", ->
assertErrorFormat '''
->
@ -28969,6 +29051,70 @@ test "#4834: dynamic import", ->
};
"""
eqJS """
console.log import('foo')
""",
"""
console.log(import('foo'));
"""
test "#5317: Support import.meta", ->
eqJS """
foo = import.meta
""",
"""
var foo;
foo = import.meta;
"""
eqJS """
foo = import
.meta
""",
"""
var foo;
foo = import.meta;
"""
eqJS """
foo = import.
meta
""",
"""
var foo;
foo = import.meta;
"""
eqJS """
foo = import.meta.bar
""",
"""
var foo;
foo = import.meta.bar;
"""
eqJS """
foo = import
.meta
.bar
""",
"""
var foo;
foo = import.meta.bar;
"""
eqJS """
console.log import.meta.url
""",
"""
console.log(import.meta.url);
"""
</script>
<script type="text/x-coffeescript" class="test" id="numbers">
# Number Literals

View file

@ -1,5 +1,5 @@
import './local-file.coffee'
import 'coffeescript'
import './local-file.js' # Must be the filename of the generated file
import 'package'
import _ from 'underscore'
import * as underscore from 'underscore'

View file

@ -0,0 +1,7 @@
```
releaseHeader('2021-09-19', '2.6.0', '2.5.1')
```
* The syntax `import.meta`, including `import.meta.url`, is now supported.
* The `await` keyword is now supported outside of functions (in other words, at the top level). [Note that JavaScript runtimes only support this for ES modules.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await)
* Bugfix for a `for` comprehension at the end of an `unless` or `until` line.

View file

@ -12,7 +12,7 @@ Once installed, you should have access to the `coffee` command, which can execut
| `-o, --output [DIR]` | Write out all compiled JavaScript files into the specified directory. Use in conjunction with `--compile` or `--watch`. |
| `-w, --watch` | Watch files for changes, rerunning the specified command when any file is updated. |
| `-p, --print` | Instead of writing out the JavaScript as a file, print it directly to **stdout**. |
| `-s, --stdio` | Pipe in CoffeeScript to STDIN and get back JavaScript over STDOUT. Good for use with processes written in other languages. An example:<br>`cat src/cake.coffee | coffee -sc` |
| `-s, --stdio` | Pipe in CoffeeScript to STDIN and get back JavaScript over STDOUT. Good for use with processes written in other languages. An example:<br><code>cat src/cake.coffee &#124; coffee -sc</code> |
| `-l, --literate` | Parses the code as Literate CoffeeScript. You only need to specify this when passing in code directly over **stdio**, or using some sort of extension-less file name. |
| `-e, --eval` | Compile and print a little snippet of CoffeeScript directly from the command line. For example:<br>`coffee -e "console.log num for num in [10..1]"` |
| `-r, --require [MODULE]`&emsp; | `require()` the given module before starting the REPL or evaluating the code given with the `--eval` flag. |

View file

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

View file

@ -1,6 +1,6 @@
## Modules
ES2015 modules are supported in CoffeeScript, with very similar `import` and `export` syntax:
[ES2015 modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) are supported in CoffeeScript, with very similar `import` and `export` syntax:
```
codeFor('modules')
@ -16,6 +16,6 @@ codeFor('dynamic_import', true)
<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 to [transpile](#transpilation) this ES2015 syntax into code that will work in your target runtimes.
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. Such statements can be run by all modern browsers (when the script is referenced via `<script type="module">`) and [by Node.js](https://nodejs.org/api/esm.html#esm_enabling) when the output `.js` files are in a folder where the nearest parent `package.json` file contains `"type": "module"`. Because the runtime is evaluating the generated output, the `import` statements must reference the output files; so if `file.coffee` is output as `file.js`, it needs to be referenced as `file.js` in the `import` statement, with the `.js` extension included.
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.
Also, 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

@ -32,7 +32,7 @@ All together now:
| `isnt` | `!==` |
| `not` | `!` |
| `and` | `&&` |
| `or` | `||` |
| `or` | <code>&#124;&#124;</code> |
| `true`, `yes`, `on` | `true` |
| `false`, `no`, `off`&emsp; | `false` |
| `@`, `this` | `this` |

View file

@ -207,6 +207,9 @@
</section>
<section id="changelog">
<%= htmlFor('changelog') %>
<section id="2.6.0">
<%= htmlFor('changelog/2.6.0') %>
</section>
<section id="2.5.1">
<%= htmlFor('changelog/2.5.1') %>
</section>

View file

@ -1,7 +1,7 @@
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<!-- The CoffeeScript logo font is Googles Galada -->
<link href="https://fonts.googleapis.com/css?family=Alegreya+Sans:400,800|Lato:300,300i,400,700|Roboto+Mono:400,400i" rel="stylesheet" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/codemirror@5.37.0/lib/codemirror.css" rel="stylesheet" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/codemirror@5.62.3/lib/codemirror.css" rel="stylesheet" crossorigin="anonymous">
<style>
<%= include('code.css') %>
<%= include('docs.css') %>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

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

View file

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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 2.5.1
// Generated by CoffeeScript 2.6.0
(function() {
// 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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

9064
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@
"compiler"
],
"author": "Jeremy Ashkenas",
"version": "2.5.1",
"version": "2.6.0",
"license": "MIT",
"engines": {
"node": ">=6"
@ -40,17 +40,16 @@
"url": "git://github.com/jashkenas/coffeescript.git"
},
"devDependencies": {
"@babel/core": "~7.7.7",
"@babel/preset-env": "~7.7.7",
"@babel/core": "~7.15.5",
"@babel/preset-env": "~7.15.6",
"babel-preset-minify": "~0.5.1",
"codemirror": "~5.52.0",
"docco": "~0.8.0",
"highlight.js": "~9.18.1",
"codemirror": "~5.62.3",
"docco": "~0.8.1",
"highlight.js": "~11.2.0",
"jison": "~0.4.18",
"markdown-it": "~10.0.0",
"puppeteer": "~3.1.0",
"underscore": "~1.9.2",
"webpack": "~4.42.0"
},
"dependencies": {}
"markdown-it": "~12.2.0",
"puppeteer": "~10.2.0",
"underscore": "~1.13.1",
"webpack": "~5.53.0"
}
}