mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-13 16:57:54 -05:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46d16b5c49 | ||
|
|
d16cf19c15 | ||
|
|
edbb9a77e7 | ||
|
|
cc4c3b2606 | ||
|
|
3a2888f97a | ||
|
|
bd17cc9b3c | ||
|
|
0a3e3639dc | ||
|
|
008bacf5d5 | ||
|
|
cc1b056b03 | ||
|
|
3548b4883e | ||
|
|
37a376497c | ||
|
|
83744917b0 | ||
|
|
a548b70e8c | ||
|
|
c8147c046a | ||
|
|
4a7497b451 | ||
|
|
06aa329596 | ||
|
|
9becb0e937 | ||
|
|
7f7765546f | ||
|
|
c7a365b6f1 | ||
|
|
84c125a71b | ||
|
|
06b74591e7 | ||
|
|
6645fbb895 | ||
|
|
c2758da9eb | ||
|
|
7a1c8fef0a | ||
|
|
71c59dddcc | ||
|
|
ef6f90753a | ||
|
|
50fff63252 | ||
|
|
8f5c77c3ce | ||
|
|
88529bc339 | ||
|
|
f37f9d1eda | ||
|
|
836175baab | ||
|
|
7395ac1d4f | ||
|
|
61988fe361 | ||
|
|
1301390087 |
50
README
50
README
@@ -1,50 +0,0 @@
|
||||
{
|
||||
} } {
|
||||
{ { } }
|
||||
} }{ {
|
||||
{ }{ } } _____ __ __
|
||||
{ }{ }{ { } / ____| / _|/ _|
|
||||
.- { { } { }} -. | | ___ | |_| |_ ___ ___
|
||||
( { } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|
||||
|`-..________ ..-'| | |___| (_) | | | || __/ __/
|
||||
| | \_____\___/|_| |_| \___|\___|
|
||||
| ;--.
|
||||
| (__ \ _____ _ _
|
||||
| | ) ) / ____| (_) | |
|
||||
| |/ / | (___ ___ _ __ _ _ __ | |_
|
||||
| ( / \___ \ / __| '__| | '_ \| __|
|
||||
| |/ ____) | (__| | | | |_) | |_
|
||||
| | |_____/ \___|_| |_| .__/ \__|
|
||||
`-.._________..-' | |
|
||||
|_|
|
||||
|
||||
|
||||
CoffeeScript is a little language that compiles into JavaScript.
|
||||
|
||||
If you have the Node Package Manager installed:
|
||||
npm install -g coffee-script
|
||||
(Leave off the -g if you don't wish to install globally.)
|
||||
|
||||
Or, if you don't wish to use npm:
|
||||
sudo bin/cake install
|
||||
|
||||
Execute a script:
|
||||
coffee /path/to/script.coffee
|
||||
|
||||
Compile a script:
|
||||
coffee -c /path/to/script.coffee
|
||||
|
||||
For documentation, usage, and examples, see:
|
||||
http://coffeescript.org/
|
||||
|
||||
To suggest a feature, report a bug, or general discussion:
|
||||
http://github.com/jashkenas/coffeescript/issues/
|
||||
|
||||
If you'd like to chat, drop by #coffeescript on Freenode IRC,
|
||||
or on webchat.freenode.net.
|
||||
|
||||
The source repository:
|
||||
git://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Top 100 contributors are listed here:
|
||||
http://github.com/jashkenas/coffeescript/contributors
|
||||
@@ -57,4 +57,6 @@ If you'd like to chat, drop by #coffeescript on Freenode IRC.
|
||||
|
||||
The source repository: https://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Changelog: http://coffeescript.org/#changelog
|
||||
|
||||
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "coffee-script",
|
||||
"version": "1.9.1",
|
||||
"version": "1.9.2",
|
||||
"main": [
|
||||
"lib/coffee-script/coffee-script.js"
|
||||
],
|
||||
|
||||
@@ -2,5 +2,5 @@ Account = (customer, cart) ->
|
||||
@customer = customer
|
||||
@cart = cart
|
||||
|
||||
$('.shopping_cart').bind 'click', (event) =>
|
||||
$('.shopping_cart').on 'click', (event) =>
|
||||
@customer.purchase @cart
|
||||
@@ -261,8 +261,9 @@ 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> <span class="hljs-function"><span class="hljs-params">(script, i)</span> -></span>
|
||||
options = <span class="hljs-attribute">literate</span>: script.type <span class="hljs-keyword">is</span> coffeetypes[<span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">if</span> script.src
|
||||
CoffeeScript.load script.src,
|
||||
source = script.src <span class="hljs-keyword">or</span> script.getAttribute(<span class="hljs-string">'data-src'</span>)
|
||||
<span class="hljs-keyword">if</span> source
|
||||
CoffeeScript.load source,
|
||||
<span class="hljs-function"><span class="hljs-params">(param)</span> -></span>
|
||||
coffees[i] = param
|
||||
execute()
|
||||
|
||||
@@ -144,7 +144,7 @@ SourceMap = <span class="hljs-built_in">require</span> <span class="hljs-str
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.VERSION = <span class="hljs-string">'1.9.1'</span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.VERSION = <span class="hljs-string">'1.9.2'</span>
|
||||
|
||||
<span class="hljs-built_in">exports</span>.FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'</span>, <span class="hljs-string">'.litcoffee'</span>, <span class="hljs-string">'.coffee.md'</span>]</pre></div></div>
|
||||
|
||||
|
||||
@@ -211,6 +211,7 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
|
||||
[ <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 [DIR]'</span>, <span class="hljs-string">'set the output directory 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">'-l'</span>, <span class="hljs-string">'--literate'</span>, <span class="hljs-string">'treat stdio as literate style coffee-script'</span>]
|
||||
[<span class="hljs-string">'-t'</span>, <span class="hljs-string">'--tokens'</span>, <span class="hljs-string">'print out the tokens that the lexer/rewriter produce'</span>]
|
||||
@@ -236,8 +237,7 @@ sources = []
|
||||
sourceCode = []
|
||||
notSources = {}
|
||||
watchedDirs = {}
|
||||
optionParser = <span class="hljs-literal">null</span>
|
||||
jsToSources = {}</pre></div></div>
|
||||
optionParser = <span class="hljs-literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -273,6 +273,8 @@ Many flags cause us to divert before compiling anything. Flags passed after
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> replCliOpts = <span class="hljs-attribute">useGlobal</span>: <span class="hljs-literal">yes</span>
|
||||
opts.prelude = makePrelude opts.<span class="hljs-built_in">require</span> <span class="hljs-keyword">if</span> opts.<span class="hljs-built_in">require</span>
|
||||
replCliOpts.prelude = opts.prelude
|
||||
<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
|
||||
@@ -303,7 +305,14 @@ Many flags cause us to divert before compiling anything. Flags passed after
|
||||
'''</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</pre></div></div>
|
||||
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> -></span>
|
||||
requires.map <span class="hljs-function"><span class="hljs-params">(<span class="hljs-built_in">module</span>)</span> -></span>
|
||||
[_, 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 ||= helpers.baseFileName <span class="hljs-built_in">module</span>, <span class="hljs-literal">yes</span>, useWinPathSep
|
||||
<span class="hljs-string">"<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>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -395,6 +404,7 @@ requested options. If evaluating the script directly sets <code>__filename</code
|
||||
printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.run
|
||||
CoffeeScript.register()
|
||||
CoffeeScript.eval opts.prelude, t.options <span class="hljs-keyword">if</span> opts.prelude
|
||||
CoffeeScript.run t.input, t.options
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.join <span class="hljs-keyword">and</span> t.file <span class="hljs-keyword">isnt</span> o.join
|
||||
t.input = helpers.invertLiterate t.input <span class="hljs-keyword">if</span> helpers.isLiterate file
|
||||
@@ -676,12 +686,6 @@ same directory as the <code>.js</code> file.</p>
|
||||
<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> -></span>
|
||||
sourceMapPath = outputPath sourcePath, base, <span class="hljs-string">".js.map"</span>
|
||||
jsDir = path.dirname jsPath
|
||||
<span class="hljs-keyword">if</span> jsPath <span class="hljs-keyword">of</span> jsToSources
|
||||
printLine <span class="hljs-string">"Error: The two following source files have the same output file:"</span>
|
||||
printLine <span class="hljs-string">" "</span> + jsToSources[jsPath]
|
||||
printLine <span class="hljs-string">" "</span> + sourcePath
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
jsToSources[jsPath] = sourcePath
|
||||
<span class="hljs-function"><span class="hljs-title">compile</span> = -></span>
|
||||
<span class="hljs-keyword">if</span> opts.compile
|
||||
js = <span class="hljs-string">' '</span> <span class="hljs-keyword">if</span> js.length <= <span class="hljs-number">0</span>
|
||||
@@ -832,7 +836,7 @@ the <code>node</code> binary, preserving the other options.</p>
|
||||
p = spawn process.execPath, nodeArgs.concat(args),
|
||||
<span class="hljs-attribute">cwd</span>: process.cwd()
|
||||
<span class="hljs-attribute">env</span>: process.env
|
||||
<span class="hljs-attribute">customFds</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
|
||||
<span class="hljs-attribute">stdio</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
|
||||
p.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -></span> process.exit code</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -583,7 +583,7 @@ it already.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> process?
|
||||
colorsEnabled = process.stdout.isTTY <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> process.env.NODE_DISABLE_COLORS
|
||||
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> <span class="hljs-property">@colorful</span> ? colorsEnabled
|
||||
<span class="hljs-function"><span class="hljs-title">colorize</span> = <span class="hljs-params">(str)</span> -></span> <span class="hljs-string">"\x1B[1;31m<span class="hljs-subst">#{str}</span>\x1B[0m"</span>
|
||||
|
||||
@@ -484,7 +484,7 @@ interpolation.</p>
|
||||
{tokens, <span class="hljs-attribute">index</span>: end} = <span class="hljs-property">@matchWithInterpolations</span> regex, quote
|
||||
$ = tokens.length - <span class="hljs-number">1</span>
|
||||
|
||||
delimiter = quote[<span class="hljs-number">0</span>]
|
||||
delimiter = quote.charAt(<span class="hljs-number">0</span>)
|
||||
<span class="hljs-keyword">if</span> heredoc</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -1766,7 +1766,7 @@ HEREDOC_INDENT = <span class="hljs-regexp">/\n+([^\n\S]*)(?=\S)/g</span></pr
|
||||
| \\[^\n] <span class="hljs-comment"># anything but newlines escaped</span>
|
||||
| \[ <span class="hljs-comment"># character class</span>
|
||||
(?: \\[^\n] | [^ \] \n \\ ] )*
|
||||
]
|
||||
\]
|
||||
)*) (/)?
|
||||
///</span>
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ object with their parent closure, to preserve the expected lexical scope.</p>
|
||||
meth = <span class="hljs-string">'call'</span>
|
||||
func = <span class="hljs-keyword">new</span> Value func, [<span class="hljs-keyword">new</span> Access <span class="hljs-keyword">new</span> Literal meth]
|
||||
parts = (<span class="hljs-keyword">new</span> Call func, args).compileNode o
|
||||
<span class="hljs-keyword">if</span> func.isGenerator
|
||||
<span class="hljs-keyword">if</span> func.isGenerator <span class="hljs-keyword">or</span> func.base?.isGenerator
|
||||
parts.unshift <span class="hljs-property">@makeCode</span> <span class="hljs-string">"(yield* "</span>
|
||||
parts.push <span class="hljs-property">@makeCode</span> <span class="hljs-string">")"</span>
|
||||
parts</pre></div></div>
|
||||
|
||||
@@ -243,11 +243,7 @@ parens. Unwrap all that.</p>
|
||||
<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>
|
||||
]
|
||||
js = ast.compile {<span class="hljs-attribute">bare</span>: <span class="hljs-literal">yes</span>, <span class="hljs-attribute">locals</span>: Object.keys(context), referencedVars}
|
||||
result = <span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
|
||||
vm.runInThisContext js, filename
|
||||
<span class="hljs-keyword">else</span>
|
||||
vm.runInContext js, context, filename
|
||||
cb <span class="hljs-literal">null</span>, result
|
||||
cb <span class="hljs-literal">null</span>, runInContext js, context, filename
|
||||
<span class="hljs-keyword">catch</span> err</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -266,6 +262,12 @@ parens. Unwrap all that.</p>
|
||||
<div class="content"><div class='highlight'><pre> updateSyntaxError err, input
|
||||
cb err
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">runInContext</span> = <span class="hljs-params">(js, context, filename)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
|
||||
vm.runInThisContext js, filename
|
||||
<span class="hljs-keyword">else</span>
|
||||
vm.runInContext js, context, filename
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">addMultilineHandler</span> = <span class="hljs-params">(repl)</span> -></span>
|
||||
{rli, inputStream, outputStream} = repl</pre></div></div>
|
||||
|
||||
@@ -576,6 +578,7 @@ parens. Unwrap all that.</p>
|
||||
process.argv = [<span class="hljs-string">'coffee'</span>].concat process.argv[<span class="hljs-number">2.</span>.]
|
||||
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"> -></span> repl.outputStream.write <span class="hljs-string">'\n'</span>
|
||||
addMultilineHandler repl
|
||||
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile</pre></div></div>
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
|
||||
<p>
|
||||
<b>Latest Version:</b>
|
||||
<a href="http://github.com/jashkenas/coffeescript/tarball/1.9.1">1.9.1</a>
|
||||
<a href="http://github.com/jashkenas/coffeescript/tarball/1.9.2">1.9.2</a>
|
||||
</p>
|
||||
|
||||
<pre>npm install -g coffee-script</pre>
|
||||
@@ -806,7 +806,7 @@ Expressions
|
||||
it to the current value of <tt>this</tt>, right on the spot. This is helpful
|
||||
when using callback-based libraries like Prototype or jQuery, for creating
|
||||
iterator functions to pass to <tt>each</tt>, or event-handler functions
|
||||
to use with <tt>bind</tt>. Functions created with the fat arrow are able to access
|
||||
to use with <tt>on</tt>. Functions created with the fat arrow are able to access
|
||||
properties of the <tt>this</tt> where they're defined.
|
||||
</p>
|
||||
<%= codeFor('fat_arrow') %>
|
||||
@@ -821,9 +821,9 @@ Expressions
|
||||
constructed.
|
||||
</p>
|
||||
<p>
|
||||
CoffeeScript functions also support
|
||||
CoffeeScript functions also support
|
||||
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">ES6 generator functions</a>
|
||||
through the <tt>yield</tt> keyword. There's no <tt>function*(){}</tt>
|
||||
through the <tt>yield</tt> keyword. There's no <tt>function*(){}</tt>
|
||||
nonsense — a generator in CoffeeScript is simply a function that yields.
|
||||
</p>
|
||||
<%= codeFor('generators', 'ps.next().value') %>
|
||||
@@ -1203,21 +1203,49 @@ Expressions
|
||||
Change Log
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
<%= releaseHeader('2015-04-15', '1.9.2', '1.9.1') %>
|
||||
<ul>
|
||||
<li>
|
||||
Fixed a <b>watch</b> mode error introduced in 1.9.1 when compiling
|
||||
multiple files with the same filename.
|
||||
</li>
|
||||
<li>
|
||||
Bugfix for <tt>yield</tt> around expressions containing
|
||||
<tt>this</tt>.
|
||||
</li>
|
||||
<li>
|
||||
Added a Ruby-style <tt>-r</tt> option to the REPL, which allows
|
||||
requiring a module before execution with <tt>--eval</tt> or
|
||||
<tt>--interactive</tt>.
|
||||
</li>
|
||||
<li>
|
||||
In <tt><script type="text/coffeescript"></tt> tags, to avoid
|
||||
possible duplicate browser requests for .coffee files,
|
||||
you can now use the <tt>data-src</tt> attribute instead of <tt>src</tt>.
|
||||
</li>
|
||||
<li>
|
||||
Minor bug fixes for IE8, strict ES5 regular expressions and Browserify.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= releaseHeader('2015-02-18', '1.9.1', '1.9.0') %>
|
||||
<ul>
|
||||
<li>
|
||||
Interpolation now works in object literal keys (again). You can use this to
|
||||
Interpolation now works in object literal keys (again). You can use this to
|
||||
dynamically name properties.
|
||||
</li>
|
||||
<li>
|
||||
Internal compiler names no longer start with underscores. This makes
|
||||
Internal compiler variable names no longer start with underscores. This makes
|
||||
the generated JavaScript a bit prettier, and also fixes an issue with
|
||||
the completely broken and ungodly way that AngularJS "parses" function
|
||||
arguments.
|
||||
</li>
|
||||
<li>
|
||||
Fixed a few <tt>yield</tt>-related bugs.
|
||||
Fixed a few <tt>yield</tt>-related edge cases with <tt>yield return</tt>
|
||||
and <tt>yield throw</tt>.
|
||||
</li>
|
||||
<li>
|
||||
Minor bug fixes and various improvements to compiler error messages.
|
||||
@@ -1230,10 +1258,10 @@ Expressions
|
||||
<ul>
|
||||
<li>
|
||||
CoffeeScript now supports ES6 generators. A generator is simply a function
|
||||
that <tt>yield</tt>s.
|
||||
that <tt>yield</tt>s.
|
||||
</li>
|
||||
<li>
|
||||
More robust parsing and improved error messages for strings and regexes —
|
||||
More robust parsing and improved error messages for strings and regexes —
|
||||
especially with respect to interpolation.
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var volume, winner;
|
||||
|
||||
if (ignition === true) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var courses, dish, food, foods, i, j, k, l, len, len1, len2, ref;
|
||||
|
||||
ref = ['toast', 'cheese', 'wine'];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
|
||||
/*
|
||||
SkinnyMochaHalfCaffScript Compiler v1.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var fs;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
$('body').click(function(e) {
|
||||
return $('.box').fadeIn('fast').addClass('.active');
|
||||
}).css('background', 'white');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var Animal, Horse, Snake, sam, tom,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var cholesterol, healthy;
|
||||
|
||||
cholesterol = 127;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var date, mood;
|
||||
|
||||
if (singing) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var Person, tim;
|
||||
|
||||
Person = (function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var fill;
|
||||
|
||||
fill = function(container, liquid) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var filename, fn, i, len;
|
||||
|
||||
fn = function(filename) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var hi;
|
||||
|
||||
hi = function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var footprints, solipsism, speed;
|
||||
|
||||
if ((typeof mind !== "undefined" && mind !== null) && (typeof world === "undefined" || world === null)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var first, last, ref, text;
|
||||
|
||||
text = "Every literary critic believes he will outwit history and have the last word";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var eldest, grade;
|
||||
|
||||
grade = function(student) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var one, six, three, two;
|
||||
|
||||
six = (one = 1) + (two = 2) + (three = 3);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var globals, name;
|
||||
|
||||
globals = ((function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var error;
|
||||
|
||||
alert((function() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var Account;
|
||||
|
||||
Account = function(customer, cart) {
|
||||
this.customer = customer;
|
||||
this.cart = cart;
|
||||
return $('.shopping_cart').bind('click', (function(_this) {
|
||||
return $('.shopping_cart').on('click', (function(_this) {
|
||||
return function(event) {
|
||||
return _this.customer.purchase(_this.cart);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var cube, square;
|
||||
|
||||
square = function(x) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var perfectSquares;
|
||||
|
||||
perfectSquares = function*() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var html;
|
||||
|
||||
html = "<strong>\n cup of coffeescript\n</strong>";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var OPERATOR;
|
||||
|
||||
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var author, quote, sentence;
|
||||
|
||||
author = "Wittgenstein";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var city, forecast, ref, temp, weatherReport;
|
||||
|
||||
weatherReport = function(location) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var age, ages, child, yearsOld;
|
||||
|
||||
yearsOld = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var city, futurists, name, ref, ref1, street;
|
||||
|
||||
futurists = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var bitlist, kids, singers, song;
|
||||
|
||||
song = ["do", "re", "mi", "fa", "so"];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
$('.account').attr({
|
||||
"class": 'active'
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var cubes, list, math, num, number, opposite, race, square,
|
||||
slice = [].slice;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var ref, theBait, theSwitch;
|
||||
|
||||
theBait = 1000;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var close, contents, i, open, ref, tag,
|
||||
slice = [].slice;
|
||||
|
||||
|
||||
2
documentation/js/prototypes.js
vendored
2
documentation/js/prototypes.js
vendored
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
String.prototype.dasherize = function() {
|
||||
return this.replace(/_/g, "-");
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var countdown, num;
|
||||
|
||||
countdown = (function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var changeNumbers, inner, outer;
|
||||
|
||||
outer = 1;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var copy, end, middle, numbers, start;
|
||||
|
||||
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var ref, zip;
|
||||
|
||||
zip = typeof lottery.drawWinner === "function" ? (ref = lottery.drawWinner().address) != null ? ref.zipcode : void 0 : void 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var awardMedals, contenders, gold, rest, silver,
|
||||
slice = [].slice;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var numbers, ref;
|
||||
|
||||
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var mobyDick;
|
||||
|
||||
mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world...";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
switch (day) {
|
||||
case "Mon":
|
||||
go(work);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var grade, score;
|
||||
|
||||
score = 76;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var error;
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
var lyrics, num;
|
||||
|
||||
if (this.studyingEconomics) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
56
index.html
56
index.html
@@ -110,7 +110,7 @@
|
||||
|
||||
<p>
|
||||
<b>Latest Version:</b>
|
||||
<a href="http://github.com/jashkenas/coffeescript/tarball/1.9.1">1.9.1</a>
|
||||
<a href="http://github.com/jashkenas/coffeescript/tarball/1.9.2">1.9.2</a>
|
||||
</p>
|
||||
|
||||
<pre>npm install -g coffee-script</pre>
|
||||
@@ -1845,26 +1845,26 @@ tim = new Person({
|
||||
it to the current value of <tt>this</tt>, right on the spot. This is helpful
|
||||
when using callback-based libraries like Prototype or jQuery, for creating
|
||||
iterator functions to pass to <tt>each</tt>, or event-handler functions
|
||||
to use with <tt>bind</tt>. Functions created with the fat arrow are able to access
|
||||
to use with <tt>on</tt>. Functions created with the fat arrow are able to access
|
||||
properties of the <tt>this</tt> where they're defined.
|
||||
</p>
|
||||
<div class='code'><pre><code><span class="function"><span class="title">Account</span> = <span class="params">(customer, cart)</span> -></span>
|
||||
<span class="property">@customer</span> = customer
|
||||
<span class="property">@cart</span> = cart
|
||||
|
||||
$<span class="function"><span class="params">(<span class="string">'.shopping_cart'</span>)</span>.<span class="title">bind</span> '<span class="title">click</span>', <span class="params">(event)</span> =></span>
|
||||
$<span class="function"><span class="params">(<span class="string">'.shopping_cart'</span>)</span>.<span class="title">on</span> '<span class="title">click</span>', <span class="params">(event)</span> =></span>
|
||||
<span class="property">@customer</span>.purchase <span class="property">@cart</span></code></pre><pre><code><span class="keyword">var</span> Account;
|
||||
|
||||
Account = <span class="function"><span class="keyword">function</span><span class="params">(customer, cart)</span> {</span>
|
||||
<span class="keyword">this</span>.customer = customer;
|
||||
<span class="keyword">this</span>.cart = cart;
|
||||
<span class="keyword">return</span> $(<span class="string">'.shopping_cart'</span>).bind(<span class="string">'click'</span>, (<span class="function"><span class="keyword">function</span><span class="params">(_this)</span> {</span>
|
||||
<span class="keyword">return</span> $(<span class="string">'.shopping_cart'</span>).on(<span class="string">'click'</span>, (<span class="function"><span class="keyword">function</span><span class="params">(_this)</span> {</span>
|
||||
<span class="keyword">return</span> <span class="function"><span class="keyword">function</span><span class="params">(event)</span> {</span>
|
||||
<span class="keyword">return</span> _this.customer.purchase(_this.cart);
|
||||
};
|
||||
})(<span class="keyword">this</span>));
|
||||
};
|
||||
</code></pre><script>window.example31 = "Account = (customer, cart) ->\n @customer = customer\n @cart = cart\n\n $('.shopping_cart').bind 'click', (event) =>\n @customer.purchase @cart"</script><div class='minibutton load' onclick='javascript: loadConsole(example31);'>load</div><br class='clear' /></div>
|
||||
</code></pre><script>window.example31 = "Account = (customer, cart) ->\n @customer = customer\n @cart = cart\n\n $('.shopping_cart').on 'click', (event) =>\n @customer.purchase @cart"</script><div class='minibutton load' onclick='javascript: loadConsole(example31);'>load</div><br class='clear' /></div>
|
||||
<p>
|
||||
If we had used <tt>-></tt> in the callback above, <tt>@customer</tt> would
|
||||
have referred to the undefined "customer" property of the DOM element,
|
||||
@@ -1876,9 +1876,9 @@ Account = <span class="function"><span class="keyword">function</span><span clas
|
||||
constructed.
|
||||
</p>
|
||||
<p>
|
||||
CoffeeScript functions also support
|
||||
CoffeeScript functions also support
|
||||
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">ES6 generator functions</a>
|
||||
through the <tt>yield</tt> keyword. There's no <tt>function*(){}</tt>
|
||||
through the <tt>yield</tt> keyword. There's no <tt>function*(){}</tt>
|
||||
nonsense — a generator in CoffeeScript is simply a function that yields.
|
||||
</p>
|
||||
<div class='code'><pre><code><span class="function"><span class="title">perfectSquares</span> = -></span>
|
||||
@@ -2491,6 +2491,37 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
|
||||
Change Log
|
||||
</h2>
|
||||
|
||||
<p>
|
||||
<div class="anchor" id="1.9.2"></div>
|
||||
<b class="header">
|
||||
<a href="https://github.com/jashkenas/coffeescript/compare/1.9.1...1.9.2">1.9.2</a>
|
||||
<span class="timestamp"> — <time datetime="2015-04-15">April 15, 2015</time></span>
|
||||
</b>
|
||||
<ul>
|
||||
<li>
|
||||
Fixed a <b>watch</b> mode error introduced in 1.9.1 when compiling
|
||||
multiple files with the same filename.
|
||||
</li>
|
||||
<li>
|
||||
Bugfix for <tt>yield</tt> around expressions containing
|
||||
<tt>this</tt>.
|
||||
</li>
|
||||
<li>
|
||||
Added a Ruby-style <tt>-r</tt> option to the REPL, which allows
|
||||
requiring a module before execution with <tt>--eval</tt> or
|
||||
<tt>--interactive</tt>.
|
||||
</li>
|
||||
<li>
|
||||
In <tt><script type="text/coffeescript"></tt> tags, to avoid
|
||||
possible duplicate browser requests for .coffee files,
|
||||
you can now use the <tt>data-src</tt> attribute instead of <tt>src</tt>.
|
||||
</li>
|
||||
<li>
|
||||
Minor bug fixes for IE8, strict ES5 regular expressions and Browserify.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<div class="anchor" id="1.9.1"></div>
|
||||
<b class="header">
|
||||
@@ -2499,17 +2530,18 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
|
||||
</b>
|
||||
<ul>
|
||||
<li>
|
||||
Interpolation now works in object literal keys (again). You can use this to
|
||||
Interpolation now works in object literal keys (again). You can use this to
|
||||
dynamically name properties.
|
||||
</li>
|
||||
<li>
|
||||
Internal compiler names no longer start with underscores. This makes
|
||||
Internal compiler variable names no longer start with underscores. This makes
|
||||
the generated JavaScript a bit prettier, and also fixes an issue with
|
||||
the completely broken and ungodly way that AngularJS "parses" function
|
||||
arguments.
|
||||
</li>
|
||||
<li>
|
||||
Fixed a few <tt>yield</tt>-related bugs.
|
||||
Fixed a few <tt>yield</tt>-related edge cases with <tt>yield return</tt>
|
||||
and <tt>yield throw</tt>.
|
||||
</li>
|
||||
<li>
|
||||
Minor bug fixes and various improvements to compiler error messages.
|
||||
@@ -2526,10 +2558,10 @@ task(<span class="string">'build:parser'</span>, <span class="string">'rebuild t
|
||||
<ul>
|
||||
<li>
|
||||
CoffeeScript now supports ES6 generators. A generator is simply a function
|
||||
that <tt>yield</tt>s.
|
||||
that <tt>yield</tt>s.
|
||||
</li>
|
||||
<li>
|
||||
More robust parsing and improved error messages for strings and regexes —
|
||||
More robust parsing and improved error messages for strings and regexes —
|
||||
especially with respect to interpolation.
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var CoffeeScript, compile, runScripts,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
@@ -104,12 +104,13 @@
|
||||
}
|
||||
};
|
||||
fn = function(script, i) {
|
||||
var options;
|
||||
var options, source;
|
||||
options = {
|
||||
literate: script.type === coffeetypes[1]
|
||||
};
|
||||
if (script.src) {
|
||||
return CoffeeScript.load(script.src, function(param) {
|
||||
source = script.src || script.getAttribute('data-src');
|
||||
if (source) {
|
||||
return CoffeeScript.load(source, function(param) {
|
||||
coffees[i] = param;
|
||||
return execute();
|
||||
}, options, true);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var Lexer, SourceMap, base, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, i, len, lexer, parser, path, ref, sourceMaps, vm, withPrettyErrors,
|
||||
hasProp = {}.hasOwnProperty,
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
SourceMap = require('./sourcemap');
|
||||
|
||||
exports.VERSION = '1.9.1';
|
||||
exports.VERSION = '1.9.2';
|
||||
|
||||
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, jsToSources, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, makePrelude, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
fs = require('fs');
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
BANNER = 'Usage: coffee [options] path/to/script.coffee -- [args]\n\nIf called without options, `coffee` will run your script.';
|
||||
|
||||
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-m', '--map', 'generate source map and save as .js.map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['--no-header', 'suppress the "Generated by" header'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-l', '--literate', 'treat stdio as literate style coffee-script'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
|
||||
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-m', '--map', 'generate source map and save as .js.map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['--no-header', 'suppress the "Generated by" header'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-r', '--require [MODULE*]', 'require the given module before eval or REPL'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-l', '--literate', 'treat stdio as literate style coffee-script'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
|
||||
|
||||
opts = {};
|
||||
|
||||
@@ -49,14 +49,16 @@
|
||||
|
||||
optionParser = null;
|
||||
|
||||
jsToSources = {};
|
||||
|
||||
exports.run = function() {
|
||||
var i, len, literals, ref1, replCliOpts, results, source;
|
||||
parseOptions();
|
||||
replCliOpts = {
|
||||
useGlobal: true
|
||||
};
|
||||
if (opts.require) {
|
||||
opts.prelude = makePrelude(opts.require);
|
||||
}
|
||||
replCliOpts.prelude = opts.prelude;
|
||||
if (opts.nodejs) {
|
||||
return forkNode();
|
||||
}
|
||||
@@ -98,6 +100,17 @@
|
||||
return results;
|
||||
};
|
||||
|
||||
makePrelude = function(requires) {
|
||||
return requires.map(function(module) {
|
||||
var _, match, name;
|
||||
if (match = module.match(/^(.*)=(.*)$/)) {
|
||||
_ = match[0], name = match[1], module = match[2];
|
||||
}
|
||||
name || (name = helpers.baseFileName(module, true, useWinPathSep));
|
||||
return name + " = require('" + module + "')";
|
||||
}).join(';');
|
||||
};
|
||||
|
||||
compilePath = function(source, topLevel, base) {
|
||||
var code, err, file, files, i, len, results, stats;
|
||||
if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
|
||||
@@ -205,6 +218,9 @@
|
||||
return printLine(CoffeeScript.nodes(t.input, t.options).toString().trim());
|
||||
} else if (o.run) {
|
||||
CoffeeScript.register();
|
||||
if (opts.prelude) {
|
||||
CoffeeScript["eval"](opts.prelude, t.options);
|
||||
}
|
||||
return CoffeeScript.run(t.input, t.options);
|
||||
} else if (o.join && t.file !== o.join) {
|
||||
if (helpers.isLiterate(file)) {
|
||||
@@ -468,13 +484,6 @@
|
||||
}
|
||||
sourceMapPath = outputPath(sourcePath, base, ".js.map");
|
||||
jsDir = path.dirname(jsPath);
|
||||
if (jsPath in jsToSources) {
|
||||
printLine("Error: The two following source files have the same output file:");
|
||||
printLine(" " + jsToSources[jsPath]);
|
||||
printLine(" " + sourcePath);
|
||||
process.exit(1);
|
||||
}
|
||||
jsToSources[jsPath] = sourcePath;
|
||||
compile = function() {
|
||||
if (opts.compile) {
|
||||
if (js.length <= 0) {
|
||||
@@ -582,7 +591,7 @@
|
||||
p = spawn(process.execPath, nodeArgs.concat(args), {
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
customFds: [0, 1, 2]
|
||||
stdio: [0, 1, 2]
|
||||
});
|
||||
return p.on('exit', function(code) {
|
||||
return process.exit(code);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;
|
||||
|
||||
@@ -201,7 +201,7 @@
|
||||
};
|
||||
|
||||
syntaxErrorToString = function() {
|
||||
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, start;
|
||||
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, ref3, ref4, start;
|
||||
if (!(this.code && this.location)) {
|
||||
return Error.prototype.toString.call(this);
|
||||
}
|
||||
@@ -218,9 +218,9 @@
|
||||
end = first_line === last_line ? last_column + 1 : codeLine.length;
|
||||
marker = codeLine.slice(0, start).replace(/[^\s]/g, ' ') + repeat('^', end - start);
|
||||
if (typeof process !== "undefined" && process !== null) {
|
||||
colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
|
||||
colorsEnabled = ((ref2 = process.stdout) != null ? ref2.isTTY : void 0) && !((ref3 = process.env) != null ? ref3.NODE_DISABLE_COLORS : void 0);
|
||||
}
|
||||
if ((ref2 = this.colorful) != null ? ref2 : colorsEnabled) {
|
||||
if ((ref4 = this.colorful) != null ? ref4 : colorsEnabled) {
|
||||
colorize = function(str) {
|
||||
return "\x1B[1;31m" + str + "\x1B[0m";
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var key, ref, val;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVALID_ESCAPE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, key, locationDataToString, ref, ref1, repeat, starts, throwSyntaxError,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
@@ -208,7 +208,7 @@
|
||||
heredoc = quote.length === 3;
|
||||
ref2 = this.matchWithInterpolations(regex, quote), tokens = ref2.tokens, end = ref2.index;
|
||||
$ = tokens.length - 1;
|
||||
delimiter = quote[0];
|
||||
delimiter = quote.charAt(0);
|
||||
if (heredoc) {
|
||||
indent = null;
|
||||
doc = ((function() {
|
||||
@@ -946,7 +946,7 @@
|
||||
|
||||
HEREDOC_INDENT = /\n+([^\n\S]*)(?=\S)/g;
|
||||
|
||||
REGEX = /^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*])*)(\/)?/;
|
||||
REGEX = /^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/;
|
||||
|
||||
REGEX_FLAGS = /^\w*/;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var Access, Arr, Assign, Base, Block, Call, Class, Code, CodeFragment, Comment, Existence, Expansion, Extends, For, HEXNUM, IDENTIFIER, IS_REGEX, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, NEGATE, NO, NUMBER, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, isComplexOrAssignable, isLiteralArguments, isLiteralThis, locationDataToString, merge, multident, parseNum, ref1, ref2, some, starts, throwSyntaxError, unfoldSoak, utility,
|
||||
extend1 = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
@@ -87,7 +87,7 @@
|
||||
};
|
||||
|
||||
Base.prototype.compileClosure = function(o) {
|
||||
var args, argumentsNode, func, jumpNode, meth, parts;
|
||||
var args, argumentsNode, func, jumpNode, meth, parts, ref3;
|
||||
if (jumpNode = this.jumps()) {
|
||||
jumpNode.error('cannot use a pure statement in an expression');
|
||||
}
|
||||
@@ -105,7 +105,7 @@
|
||||
func = new Value(func, [new Access(new Literal(meth))]);
|
||||
}
|
||||
parts = (new Call(func, args)).compileNode(o);
|
||||
if (func.isGenerator) {
|
||||
if (func.isGenerator || ((ref3 = func.base) != null ? ref3.isGenerator : void 0)) {
|
||||
parts.unshift(this.makeCode("(yield* "));
|
||||
parts.push(this.makeCode(")"));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, ref, replDefaults, updateSyntaxError, vm;
|
||||
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, ref, replDefaults, runInContext, updateSyntaxError, vm;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
|
||||
historyMaxInputSize: 10240,
|
||||
"eval": function(input, context, filename, cb) {
|
||||
var Assign, Block, Literal, Value, ast, err, js, ref1, referencedVars, result, token, tokens;
|
||||
var Assign, Block, Literal, Value, ast, err, js, ref1, referencedVars, token, tokens;
|
||||
input = input.replace(/\uFF00/g, '\n');
|
||||
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1');
|
||||
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
|
||||
@@ -43,8 +43,7 @@
|
||||
locals: Object.keys(context),
|
||||
referencedVars: referencedVars
|
||||
});
|
||||
result = context === global ? vm.runInThisContext(js, filename) : vm.runInContext(js, context, filename);
|
||||
return cb(null, result);
|
||||
return cb(null, runInContext(js, context, filename));
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
updateSyntaxError(err, input);
|
||||
@@ -53,6 +52,14 @@
|
||||
}
|
||||
};
|
||||
|
||||
runInContext = function(js, context, filename) {
|
||||
if (context === global) {
|
||||
return vm.runInThisContext(js, filename);
|
||||
} else {
|
||||
return vm.runInContext(js, context, filename);
|
||||
}
|
||||
};
|
||||
|
||||
addMultilineHandler = function(repl) {
|
||||
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, ref1, rli;
|
||||
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream;
|
||||
@@ -174,6 +181,9 @@
|
||||
process.argv = ['coffee'].concat(process.argv.slice(2));
|
||||
opts = merge(replDefaults, opts);
|
||||
repl = nodeREPL.start(opts);
|
||||
if (opts.prelude) {
|
||||
runInContext(opts.prelude, repl.context, 'prelude');
|
||||
}
|
||||
repl.on('exit', function() {
|
||||
return repl.outputStream.write('\n');
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, k, left, len, ref, rite,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var Scope,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.2
|
||||
(function() {
|
||||
var LineMap, SourceMap;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"compiler"
|
||||
],
|
||||
"author": "Jeremy Ashkenas",
|
||||
"version": "1.9.1",
|
||||
"version": "1.9.2",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
|
||||
@@ -69,8 +69,9 @@ runScripts = ->
|
||||
for script, i in coffees
|
||||
do (script, i) ->
|
||||
options = literate: script.type is coffeetypes[1]
|
||||
if script.src
|
||||
CoffeeScript.load script.src,
|
||||
source = script.src or script.getAttribute('data-src')
|
||||
if source
|
||||
CoffeeScript.load source,
|
||||
(param) ->
|
||||
coffees[i] = param
|
||||
execute()
|
||||
|
||||
@@ -12,7 +12,7 @@ helpers = require './helpers'
|
||||
SourceMap = require './sourcemap'
|
||||
|
||||
# The current CoffeeScript version number.
|
||||
exports.VERSION = '1.9.1'
|
||||
exports.VERSION = '1.9.2'
|
||||
|
||||
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md']
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ SWITCHES = [
|
||||
[ '--no-header', 'suppress the "Generated by" header']
|
||||
['-o', '--output [DIR]', 'set the output directory for compiled JavaScript']
|
||||
['-p', '--print', 'print out the compiled JavaScript']
|
||||
['-r', '--require [MODULE*]', 'require the given module before eval or REPL']
|
||||
['-s', '--stdio', 'listen for and compile scripts over stdio']
|
||||
['-l', '--literate', 'treat stdio as literate style coffee-script']
|
||||
['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce']
|
||||
@@ -58,7 +59,6 @@ sourceCode = []
|
||||
notSources = {}
|
||||
watchedDirs = {}
|
||||
optionParser = null
|
||||
jsToSources = {}
|
||||
|
||||
# Run `coffee` by parsing passed options and determining what action to take.
|
||||
# Many flags cause us to divert before compiling anything. Flags passed after
|
||||
@@ -69,6 +69,8 @@ exports.run = ->
|
||||
# `node` REPL CLI and, therefore, (b) make packages that modify native prototypes
|
||||
# (such as 'colors' and 'sugar') work as expected.
|
||||
replCliOpts = useGlobal: yes
|
||||
opts.prelude = makePrelude opts.require if opts.require
|
||||
replCliOpts.prelude = opts.prelude
|
||||
return forkNode() if opts.nodejs
|
||||
return usage() if opts.help
|
||||
return version() if opts.version
|
||||
@@ -101,6 +103,13 @@ exports.run = ->
|
||||
source = path.resolve source
|
||||
compilePath source, yes, source
|
||||
|
||||
makePrelude = (requires) ->
|
||||
requires.map (module) ->
|
||||
[_, name, module] = match if match = module.match(/^(.*)=(.*)$/)
|
||||
name ||= helpers.baseFileName module, yes, useWinPathSep
|
||||
"#{name} = require('#{module}')"
|
||||
.join ';'
|
||||
|
||||
# Compile a path, which could be a script or a directory. If a directory
|
||||
# is passed, recursively compile all '.coffee', '.litcoffee', and '.coffee.md'
|
||||
# extension source files in it and all subdirectories.
|
||||
@@ -167,6 +176,7 @@ compileScript = (file, input, base = null) ->
|
||||
printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
|
||||
else if o.run
|
||||
CoffeeScript.register()
|
||||
CoffeeScript.eval opts.prelude, t.options if opts.prelude
|
||||
CoffeeScript.run t.input, t.options
|
||||
else if o.join and t.file isnt o.join
|
||||
t.input = helpers.invertLiterate t.input if helpers.isLiterate file
|
||||
@@ -353,12 +363,6 @@ mkdirp = (dir, fn) ->
|
||||
writeJs = (base, sourcePath, js, jsPath, generatedSourceMap = null) ->
|
||||
sourceMapPath = outputPath sourcePath, base, ".js.map"
|
||||
jsDir = path.dirname jsPath
|
||||
if jsPath of jsToSources
|
||||
printLine "Error: The two following source files have the same output file:"
|
||||
printLine " " + jsToSources[jsPath]
|
||||
printLine " " + sourcePath
|
||||
process.exit 1
|
||||
jsToSources[jsPath] = sourcePath
|
||||
compile = ->
|
||||
if opts.compile
|
||||
js = ' ' if js.length <= 0
|
||||
@@ -437,7 +441,7 @@ forkNode = ->
|
||||
p = spawn process.execPath, nodeArgs.concat(args),
|
||||
cwd: process.cwd()
|
||||
env: process.env
|
||||
customFds: [0, 1, 2]
|
||||
stdio: [0, 1, 2]
|
||||
p.on 'exit', (code) -> process.exit code
|
||||
|
||||
# Print the `--help` usage message and exit. Deprecated switches are not
|
||||
|
||||
@@ -173,7 +173,7 @@ syntaxErrorToString = ->
|
||||
|
||||
# Check to see if we're running on a color-enabled TTY.
|
||||
if process?
|
||||
colorsEnabled = process.stdout.isTTY and not process.env.NODE_DISABLE_COLORS
|
||||
colorsEnabled = process.stdout?.isTTY and not process.env?.NODE_DISABLE_COLORS
|
||||
|
||||
if @colorful ? colorsEnabled
|
||||
colorize = (str) -> "\x1B[1;31m#{str}\x1B[0m"
|
||||
|
||||
@@ -204,7 +204,7 @@ exports.Lexer = class Lexer
|
||||
{tokens, index: end} = @matchWithInterpolations regex, quote
|
||||
$ = tokens.length - 1
|
||||
|
||||
delimiter = quote[0]
|
||||
delimiter = quote.charAt(0)
|
||||
if heredoc
|
||||
# Find the smallest indentation. It will be removed from all lines later.
|
||||
indent = null
|
||||
@@ -841,7 +841,7 @@ REGEX = /// ^
|
||||
| \\[^\n] # anything but newlines escaped
|
||||
| \[ # character class
|
||||
(?: \\[^\n] | [^ \] \n \\ ] )*
|
||||
]
|
||||
\]
|
||||
)*) (/)?
|
||||
///
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ exports.Base = class Base
|
||||
meth = 'call'
|
||||
func = new Value func, [new Access new Literal meth]
|
||||
parts = (new Call func, args).compileNode o
|
||||
if func.isGenerator
|
||||
if func.isGenerator or func.base?.isGenerator
|
||||
parts.unshift @makeCode "(yield* "
|
||||
parts.push @makeCode ")"
|
||||
parts
|
||||
|
||||
@@ -33,16 +33,18 @@ replDefaults =
|
||||
new Assign (new Value new Literal '_'), ast, '='
|
||||
]
|
||||
js = ast.compile {bare: yes, locals: Object.keys(context), referencedVars}
|
||||
result = if context is global
|
||||
vm.runInThisContext js, filename
|
||||
else
|
||||
vm.runInContext js, context, filename
|
||||
cb null, result
|
||||
cb null, runInContext js, context, filename
|
||||
catch err
|
||||
# AST's `compile` does not add source code information to syntax errors.
|
||||
updateSyntaxError err, input
|
||||
cb err
|
||||
|
||||
runInContext = (js, context, filename) ->
|
||||
if context is global
|
||||
vm.runInThisContext js, filename
|
||||
else
|
||||
vm.runInContext js, context, filename
|
||||
|
||||
addMultilineHandler = (repl) ->
|
||||
{rli, inputStream, outputStream} = repl
|
||||
# Node 0.11.12 changed API, prompt is now _prompt.
|
||||
@@ -149,6 +151,7 @@ module.exports =
|
||||
process.argv = ['coffee'].concat process.argv[2..]
|
||||
opts = merge replDefaults, opts
|
||||
repl = nodeREPL.start opts
|
||||
runInContext opts.prelude, repl.context, 'prelude' if opts.prelude
|
||||
repl.on 'exit', -> repl.outputStream.write '\n'
|
||||
addMultilineHandler repl
|
||||
addHistory repl, opts.historyFile, opts.historyMaxInputSize if opts.historyFile
|
||||
|
||||
@@ -162,7 +162,7 @@ test "variable swapping to verify caching of RHS values when appropriate", ->
|
||||
eq nonceB, b
|
||||
eq nonceC, c
|
||||
|
||||
test "#713", ->
|
||||
test "#713: destructuring assignment should return right-hand-side value", ->
|
||||
nonces = [nonceA={},nonceB={}]
|
||||
eq nonces, [a, b] = [c, d] = nonces
|
||||
eq nonceA, a
|
||||
@@ -247,7 +247,7 @@ test "destructuring assignment with context (@) properties", ->
|
||||
eq d, obj.d
|
||||
eq e, obj.e
|
||||
|
||||
test "#1024", ->
|
||||
test "#1024: destructure empty assignments to produce javascript-like results", ->
|
||||
eq 2 * [] = 3 + 5, 16
|
||||
|
||||
test "#1005: invalid identifiers allowed on LHS of destructuring assignment", ->
|
||||
|
||||
@@ -81,7 +81,7 @@ test "#2516: Unicode spaces should not be part of identifiers", ->
|
||||
test "don't accidentally stringify keywords", ->
|
||||
ok (-> this == 'this')() is false
|
||||
|
||||
test "#1026", ->
|
||||
test "#1026: no if/else/else allowed", ->
|
||||
cantCompile '''
|
||||
if a
|
||||
b
|
||||
@@ -91,7 +91,7 @@ test "#1026", ->
|
||||
d
|
||||
'''
|
||||
|
||||
test "#1050", ->
|
||||
test "#1050: no closing asterisk comments from within block comments", ->
|
||||
cantCompile "### */ ###"
|
||||
|
||||
test "#1273: escaping quotes at the end of heredocs", ->
|
||||
|
||||
@@ -186,7 +186,7 @@ test "tight formatting with leading `then`", ->
|
||||
then nonce
|
||||
else undefined
|
||||
|
||||
test "#738", ->
|
||||
test "#738: inline function defintion", ->
|
||||
nonce = {}
|
||||
fn = if true then -> nonce
|
||||
eq nonce, fn()
|
||||
|
||||
@@ -218,3 +218,50 @@ test "symbolic operators has precedence over the `yield`", ->
|
||||
mapped = CoffeeScript.eval "(arr) -> (#{expression} for i in arr)"
|
||||
|
||||
arrayEq mapped(values), collect yielded values
|
||||
|
||||
test "yield handles 'this' correctly", ->
|
||||
x = ->
|
||||
yield switch
|
||||
when true then yield => this
|
||||
yield for item in [1]
|
||||
yield => this
|
||||
yield if true then yield => this
|
||||
yield try throw yield => this
|
||||
throw yield => this
|
||||
|
||||
y = x.call [1, 2, 3]
|
||||
|
||||
z = y.next()
|
||||
arrayEq z.value(), [1, 2, 3]
|
||||
ok z.done is false
|
||||
|
||||
z = y.next 123
|
||||
ok z.value is 123 and z.done is false
|
||||
|
||||
z = y.next()
|
||||
arrayEq z.value(), [1, 2, 3]
|
||||
ok z.done is false
|
||||
|
||||
z = y.next 42
|
||||
arrayEq z.value, [42]
|
||||
ok z.done is false
|
||||
|
||||
z = y.next()
|
||||
arrayEq z.value(), [1, 2, 3]
|
||||
ok z.done is false
|
||||
|
||||
z = y.next 456
|
||||
ok z.value is 456 and z.done is false
|
||||
|
||||
z = y.next()
|
||||
arrayEq z.value(), [1, 2, 3]
|
||||
ok z.done is false
|
||||
|
||||
z = y.next new Error "ignore me"
|
||||
ok z.value is undefined and z.done is false
|
||||
|
||||
z = y.next()
|
||||
arrayEq z.value(), [1, 2, 3]
|
||||
ok z.done is false
|
||||
|
||||
throws -> y.next new Error "boom"
|
||||
|
||||
@@ -52,11 +52,10 @@ test "function invocation with soaked property access", ->
|
||||
test "if-to-ternary should safely parenthesize soaked property accesses", ->
|
||||
ok (if nonexistent?.property then false else true)
|
||||
|
||||
test "#726", ->
|
||||
# TODO: check this test, looks like it's not really testing anything
|
||||
test "#726: don't check for a property on a conditionally-referenced nonexistent thing", ->
|
||||
eq undefined, nonexistent?[Date()]
|
||||
|
||||
test "#756", ->
|
||||
test "#756: conditional assignment edge cases", ->
|
||||
# TODO: improve this test
|
||||
a = null
|
||||
ok isNaN a?.b.c + 1
|
||||
@@ -88,7 +87,7 @@ test "soaked method invocation", ->
|
||||
eq obj , obj.increment().increment().self?()
|
||||
eq 2 , counter
|
||||
|
||||
test "#733", ->
|
||||
test "#733: conditional assignments", ->
|
||||
a = b: {c: null}
|
||||
eq a.b?.c?(), undefined
|
||||
a.b?.c or= (it) -> it
|
||||
|
||||
Reference in New Issue
Block a user