Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CoffeeScript 0.6.0 is on the books.

  • Loading branch information...
commit c067808b54e8f7d022156959e3aa47217cd96f88 1 parent 59ae79d
@jashkenas jashkenas authored
View
20 README
@@ -39,4 +39,22 @@
The source repository:
git://github.com/jashkenas/coffee-script.git
-
+
+
+ Contributors:
+
+ Stan Angeloff (StanAngeloff)
+ Jeremy Ashkenas (jashkenas)
+ Zach Carter (zaach)
+ Tim Cuthbertson (gfxmonk)
+ Mathieu D'Amours (matehat)
+ Chris Hoffman (cehoffman)
+ Jason Huggins (hugs)
+ Tim Jones (Tesco)
+ Matt Lyon (mattly)
+ Jeff Olson (olsonjeffery)
+ Samuel Reis (grgh)
+ Tom Robinson (tlrobinson)
+ Tim Smart (Tim-Smart)
+ Dr. Nic Williams (drnic)
+
View
2  documentation/docs/coffee-script.html
@@ -16,7 +16,7 @@
<span class="k">this</span><span class="p">.</span><span class="nv">exports: </span><span class="k">this</span><span class="p">.</span><span class="nv">CoffeeScript: </span><span class="p">{}</span>
<span class="nv">Lexer: </span> <span class="k">this</span><span class="p">.</span><span class="nx">Lexer</span>
<span class="nv">parser: </span> <span class="k">this</span><span class="p">.</span><span class="nx">parser</span>
- <span class="nv">helpers: </span> <span class="k">this</span><span class="p">.</span><span class="nx">helpers</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-3">#</a> </div> <p>The current CoffeeScript version number.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.VERSION: </span><span class="s1">&#39;0.5.6&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-4">#</a> </div> <p>Instantiate a Lexer for our use here.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">lexer: </span><span class="k">new</span> <span class="nx">Lexer</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</a> </div> <p>Compile a string of CoffeeScript code to JavaScript, using the Coffee/Jison
+ <span class="nv">helpers: </span> <span class="k">this</span><span class="p">.</span><span class="nx">helpers</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-3">#</a> </div> <p>The current CoffeeScript version number.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.VERSION: </span><span class="s1">&#39;0.6.0&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-4">#</a> </div> <p>Instantiate a Lexer for our use here.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">lexer: </span><span class="k">new</span> <span class="nx">Lexer</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-5">#</a> </div> <p>Compile a string of CoffeeScript code to JavaScript, using the Coffee/Jison
compiler.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">exports.compile: compile: </span><span class="p">(</span><span class="nx">code</span><span class="p">,</span> <span class="nx">options</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nv">options: </span><span class="o">or</span> <span class="p">{}</span>
<span class="k">try</span>
View
14 documentation/docs/underscore.html
@@ -23,7 +23,7 @@
<span class="nv">nativeIndexOf: </span> <span class="nx">ArrayProto</span><span class="p">.</span><span class="nx">indexOf</span>
<span class="nv">nativeLastIndexOf: </span> <span class="nx">ArrayProto</span><span class="p">.</span><span class="nx">lastIndexOf</span>
<span class="nv">nativeIsArray: </span> <span class="nb">Array</span><span class="p">.</span><span class="nx">isArray</span>
- <span class="nv">nativeKeys: </span> <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-11">#</a> </div> <p>Create a safe reference to the Underscore object for use below.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_: </span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">wrapper</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-12">#</a> </div> <p>Export the Underscore object for <strong>CommonJS</strong>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="k">typeof</span><span class="p">(</span><span class="nx">exports</span><span class="p">)</span> <span class="o">!=</span> <span class="s1">&#39;undefined&#39;</span> <span class="k">then</span> <span class="nv">exports._: </span><span class="nx">_</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-13">#</a> </div> <p>Export Underscore to global scope.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">root._: </span><span class="nx">_</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-14">#</a> </div> <p>Current version.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.VERSION: </span><span class="s1">&#39;0.6.0&#39;</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-15">#</a> </div> <h2>Collection Functions</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-16">#</a> </div> <p>The cornerstone, an <strong>each</strong> implementation.
+ <span class="nv">nativeKeys: </span> <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-11">#</a> </div> <p>Create a safe reference to the Underscore object for use below.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_: </span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">new</span> <span class="nx">wrapper</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-12">#</a> </div> <p>Export the Underscore object for <strong>CommonJS</strong>.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">if</span> <span class="k">typeof</span><span class="p">(</span><span class="nx">exports</span><span class="p">)</span> <span class="o">!=</span> <span class="s1">&#39;undefined&#39;</span> <span class="k">then</span> <span class="nv">exports._: </span><span class="nx">_</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-13">#</a> </div> <p>Export Underscore to global scope.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">root._: </span><span class="nx">_</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-14">#</a> </div> <p>Current version.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.VERSION: </span><span class="s1">&#39;1.0.2&#39;</span></pre></div> </td> </tr> <tr id="section-15"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-15">#</a> </div> <h2>Collection Functions</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-16"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-16">#</a> </div> <p>The cornerstone, an <strong>each</strong> implementation.
Handles objects implementing <strong>forEach</strong>, arrays, and raw objects.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.each: </span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">iterator</span><span class="p">,</span> <span class="nx">context</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">try</span>
<span class="k">if</span> <span class="nx">nativeForEach</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">forEach</span> <span class="o">is</span> <span class="nx">nativeForEach</span>
@@ -202,9 +202,10 @@
<span class="k">return</span> <span class="nx">_</span><span class="p">.</span><span class="nx">range</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">length</span> <span class="k">if</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span>
<span class="nx">key</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span> <span class="k">of</span> <span class="nx">obj</span></pre></div> </td> </tr> <tr id="section-56"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-56">#</a> </div> <p>Retrieve the values of an object's properties.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.values: </span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="nx">_</span><span class="p">.</span><span class="nx">map</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">_</span><span class="p">.</span><span class="nx">identity</span></pre></div> </td> </tr> <tr id="section-57"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-57">#</a> </div> <p>Return a sorted list of the function names available in Underscore.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.functions: </span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span>
- <span class="nx">_</span><span class="p">.</span><span class="nx">filter</span><span class="p">(</span><span class="nx">_</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">obj</span><span class="p">),</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isFunction</span><span class="p">(</span><span class="nx">obj</span><span class="p">[</span><span class="nx">key</span><span class="p">])).</span><span class="nx">sort</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-58"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-58">#</a> </div> <p>Extend a given object with all of the properties in a source object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.extend: </span><span class="p">(</span><span class="nx">destination</span><span class="p">,</span> <span class="nx">source</span><span class="p">)</span> <span class="o">-&gt;</span>
- <span class="p">(</span><span class="nx">destination</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span><span class="o">:</span> <span class="nx">val</span><span class="p">)</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span> <span class="k">of</span> <span class="nx">source</span>
- <span class="nx">destination</span></pre></div> </td> </tr> <tr id="section-59"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-59">#</a> </div> <p>Create a (shallow-cloned) duplicate of an object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.clone: </span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span>
+ <span class="nx">_</span><span class="p">.</span><span class="nx">filter</span><span class="p">(</span><span class="nx">_</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">obj</span><span class="p">),</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isFunction</span><span class="p">(</span><span class="nx">obj</span><span class="p">[</span><span class="nx">key</span><span class="p">])).</span><span class="nx">sort</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-58"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-58">#</a> </div> <p>Extend a given object with all of the properties in a source object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.extend: </span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span>
+ <span class="k">for</span> <span class="nx">source</span> <span class="k">in</span> <span class="nx">_</span><span class="p">.</span><span class="nx">rest</span><span class="p">(</span><span class="nx">arguments</span><span class="p">)</span>
+ <span class="p">(</span><span class="nx">obj</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span><span class="o">:</span> <span class="nx">val</span><span class="p">)</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span> <span class="k">of</span> <span class="nx">source</span>
+ <span class="nx">obj</span></pre></div> </td> </tr> <tr id="section-59"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-59">#</a> </div> <p>Create a (shallow-cloned) duplicate of an object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.clone: </span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">return</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">slice</span> <span class="mi">0</span> <span class="k">if</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isArray</span> <span class="nx">obj</span>
<span class="nx">_</span><span class="p">.</span><span class="nx">extend</span> <span class="p">{},</span> <span class="nx">obj</span></pre></div> </td> </tr> <tr id="section-60"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-60">#</a> </div> <p>Invokes interceptor with the obj, and then returns obj.
The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.tap: </span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">interceptor</span><span class="p">)</span> <span class="o">-&gt;</span>
@@ -214,12 +215,11 @@
<span class="k">return</span> <span class="nx">a</span><span class="p">.</span><span class="nx">source</span> <span class="o">is</span> <span class="nx">b</span><span class="p">.</span><span class="nx">source</span> <span class="o">and</span>
<span class="nx">a</span><span class="p">.</span><span class="nx">global</span> <span class="o">is</span> <span class="nx">b</span><span class="p">.</span><span class="nx">global</span> <span class="o">and</span>
<span class="nx">a</span><span class="p">.</span><span class="nx">ignoreCase</span> <span class="o">is</span> <span class="nx">b</span><span class="p">.</span><span class="nx">ignoreCase</span> <span class="o">and</span>
- <span class="nx">a</span><span class="p">.</span><span class="nx">multiline</span> <span class="o">is</span> <span class="nx">b</span><span class="p">.</span><span class="nx">multiline</span></pre></div> </td> </tr> <tr id="section-70"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-70">#</a> </div> <p>If a is not an object by this point, we can't handle it.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="kc">false</span> <span class="k">if</span> <span class="nx">atype</span> <span class="o">isnt</span> <span class="s1">&#39;object&#39;</span></pre></div> </td> </tr> <tr id="section-71"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-71">#</a> </div> <p>Check for different array lengths before comparing contents.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="kc">false</span> <span class="k">if</span> <span class="nx">a</span><span class="p">.</span><span class="nx">length</span> <span class="o">and</span> <span class="p">(</span><span class="nx">a</span><span class="p">.</span><span class="nx">length</span> <span class="o">isnt</span> <span class="nx">b</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-72"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-72">#</a> </div> <p>Nothing else worked, deep compare the contents.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">aKeys: </span><span class="nx">_</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">a</span><span class="p">);</span> <span class="nv">bKeys: </span><span class="nx">_</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">b</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-73"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-73">#</a> </div> <p>Different object sizes?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="kc">false</span> <span class="k">if</span> <span class="nx">aKeys</span><span class="p">.</span><span class="nx">length</span> <span class="o">isnt</span> <span class="nx">bKeys</span><span class="p">.</span><span class="nx">length</span></pre></div> </td> </tr> <tr id="section-74"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-74">#</a> </div> <p>Recursive comparison of contents.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="p">(</span><span class="k">return</span> <span class="kc">false</span><span class="p">)</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span> <span class="k">of</span> <span class="nx">a</span> <span class="k">when</span> <span class="o">!</span><span class="nx">_</span><span class="p">.</span><span class="nx">isEqual</span><span class="p">(</span><span class="nx">val</span><span class="p">,</span> <span class="nx">b</span><span class="p">[</span><span class="nx">key</span><span class="p">])</span>
+ <span class="nx">a</span><span class="p">.</span><span class="nx">multiline</span> <span class="o">is</span> <span class="nx">b</span><span class="p">.</span><span class="nx">multiline</span></pre></div> </td> </tr> <tr id="section-70"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-70">#</a> </div> <p>If a is not an object by this point, we can't handle it.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="kc">false</span> <span class="k">if</span> <span class="nx">atype</span> <span class="o">isnt</span> <span class="s1">&#39;object&#39;</span></pre></div> </td> </tr> <tr id="section-71"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-71">#</a> </div> <p>Check for different array lengths before comparing contents.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="kc">false</span> <span class="k">if</span> <span class="nx">a</span><span class="p">.</span><span class="nx">length</span> <span class="o">and</span> <span class="p">(</span><span class="nx">a</span><span class="p">.</span><span class="nx">length</span> <span class="o">isnt</span> <span class="nx">b</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-72"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-72">#</a> </div> <p>Nothing else worked, deep compare the contents.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">aKeys: </span><span class="nx">_</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">a</span><span class="p">);</span> <span class="nv">bKeys: </span><span class="nx">_</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">b</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-73"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-73">#</a> </div> <p>Different object sizes?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="k">return</span> <span class="kc">false</span> <span class="k">if</span> <span class="nx">aKeys</span><span class="p">.</span><span class="nx">length</span> <span class="o">isnt</span> <span class="nx">bKeys</span><span class="p">.</span><span class="nx">length</span></pre></div> </td> </tr> <tr id="section-74"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-74">#</a> </div> <p>Recursive comparison of contents.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="p">(</span><span class="k">return</span> <span class="kc">false</span><span class="p">)</span> <span class="k">for</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span> <span class="k">of</span> <span class="nx">a</span> <span class="k">when</span> <span class="o">!</span><span class="p">(</span><span class="nx">key</span> <span class="k">in</span> <span class="nx">b</span><span class="p">)</span> <span class="o">or</span> <span class="o">!</span><span class="nx">_</span><span class="p">.</span><span class="nx">isEqual</span><span class="p">(</span><span class="nx">val</span><span class="p">,</span> <span class="nx">b</span><span class="p">[</span><span class="nx">key</span><span class="p">])</span>
<span class="kc">true</span></pre></div> </td> </tr> <tr id="section-75"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-75">#</a> </div> <p>Is a given array or object empty?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isEmpty: </span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span>
<span class="k">return</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">length</span> <span class="o">is</span> <span class="mi">0</span> <span class="k">if</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isArray</span> <span class="nx">obj</span>
<span class="p">(</span><span class="k">return</span> <span class="kc">false</span><span class="p">)</span> <span class="k">for</span> <span class="nx">key</span> <span class="k">of</span> <span class="nx">obj</span> <span class="k">when</span> <span class="nx">hasOwnProperty</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="nx">key</span><span class="p">)</span>
- <span class="kc">true</span></pre></div> </td> </tr> <tr id="section-76"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-76">#</a> </div> <p>Is a given value a DOM element?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isElement: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">is</span> <span class="mi">1</span></pre></div> </td> </tr> <tr id="section-77"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-77">#</a> </div> <p>Is a given value an array?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isArray: </span> <span class="nx">nativeIsArray</span> <span class="o">or</span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">concat</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">unshift</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-78"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-78">#</a> </div> <p>Is a given variable an arguments object?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isArguments: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">obj</span> <span class="o">and</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isNumber</span><span class="p">(</span><span class="nx">obj</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">concat</span> <span class="o">and</span>
- <span class="o">not</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">substr</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">apply</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">propertyIsEnumerable</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">obj</span><span class="p">,</span> <span class="s1">&#39;length&#39;</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-79"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-79">#</a> </div> <p>Is the given value a function?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isFunction: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">constructor</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">call</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">apply</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-80"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-80">#</a> </div> <p>Is the given value a string?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isString: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">is</span> <span class="s1">&#39;&#39;</span> <span class="o">or</span> <span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">charCodeAt</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">substr</span><span class="p">))</span></pre></div> </td> </tr> <tr id="section-81"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-81">#</a> </div> <p>Is a given value a number?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isNumber: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="nx">obj</span> <span class="o">is</span> <span class="o">+</span><span class="nx">obj</span><span class="p">)</span> <span class="o">or</span> <span class="nx">toString</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;[object Number]&#39;</span></pre></div> </td> </tr> <tr id="section-82"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-82">#</a> </div> <p>Is a given value a boolean?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isBoolean: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">obj</span> <span class="o">is</span> <span class="kc">true</span> <span class="o">or</span> <span class="nx">obj</span> <span class="o">is</span> <span class="kc">false</span></pre></div> </td> </tr> <tr id="section-83"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-83">#</a> </div> <p>Is a given value a Date?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isDate: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">getTimezoneOffset</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">setUTCFullYear</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-84"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-84">#</a> </div> <p>Is the given value a regular expression?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isRegExp: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">exec</span> <span class="o">and</span> <span class="p">(</span><span class="nx">obj</span><span class="p">.</span><span class="nx">ignoreCase</span> <span class="o">or</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">ignoreCase</span> <span class="o">is</span> <span class="kc">false</span><span class="p">))</span></pre></div> </td> </tr> <tr id="section-85"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-85">#</a> </div> <p>Is the given value NaN -- this one is interesting. <code>NaN != NaN</code>, and
+ <span class="kc">true</span></pre></div> </td> </tr> <tr id="section-76"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-76">#</a> </div> <p>Is a given value a DOM element?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isElement: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">nodeType</span> <span class="o">is</span> <span class="mi">1</span></pre></div> </td> </tr> <tr id="section-77"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-77">#</a> </div> <p>Is a given value an array?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isArray: </span> <span class="nx">nativeIsArray</span> <span class="o">or</span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">concat</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">unshift</span> <span class="o">and</span> <span class="o">not</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">callee</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-78"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-78">#</a> </div> <p>Is a given variable an arguments object?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isArguments: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">callee</span></pre></div> </td> </tr> <tr id="section-79"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-79">#</a> </div> <p>Is the given value a function?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isFunction: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">constructor</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">call</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">apply</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-80"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-80">#</a> </div> <p>Is the given value a string?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isString: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">is</span> <span class="s1">&#39;&#39;</span> <span class="o">or</span> <span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">charCodeAt</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">substr</span><span class="p">))</span></pre></div> </td> </tr> <tr id="section-81"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-81">#</a> </div> <p>Is a given value a number?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isNumber: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="nx">obj</span> <span class="o">is</span> <span class="o">+</span><span class="nx">obj</span><span class="p">)</span> <span class="o">or</span> <span class="nx">toString</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">is</span> <span class="s1">&#39;[object Number]&#39;</span></pre></div> </td> </tr> <tr id="section-82"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-82">#</a> </div> <p>Is a given value a boolean?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isBoolean: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">obj</span> <span class="o">is</span> <span class="kc">true</span> <span class="o">or</span> <span class="nx">obj</span> <span class="o">is</span> <span class="kc">false</span></pre></div> </td> </tr> <tr id="section-83"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-83">#</a> </div> <p>Is a given value a Date?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isDate: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">getTimezoneOffset</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">setUTCFullYear</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-84"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-84">#</a> </div> <p>Is the given value a regular expression?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isRegExp: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="o">!!</span><span class="p">(</span><span class="nx">obj</span> <span class="o">and</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">exec</span> <span class="o">and</span> <span class="p">(</span><span class="nx">obj</span><span class="p">.</span><span class="nx">ignoreCase</span> <span class="o">or</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">ignoreCase</span> <span class="o">is</span> <span class="kc">false</span><span class="p">))</span></pre></div> </td> </tr> <tr id="section-85"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-85">#</a> </div> <p>Is the given value NaN -- this one is interesting. <code>NaN != NaN</code>, and
<code>isNaN(undefined) == true</code>, so we make sure it's a number first.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isNaN: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isNumber</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">and</span> <span class="nb">window</span><span class="p">.</span><span class="nb">isNaN</span><span class="p">(</span><span class="nx">obj</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-86"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-86">#</a> </div> <p>Is a given value equal to null?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isNull: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nx">obj</span> <span class="o">is</span> <span class="kc">null</span></pre></div> </td> </tr> <tr id="section-87"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-87">#</a> </div> <p>Is a given variable undefined?</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.isUndefined: </span> <span class="p">(</span><span class="nx">obj</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="k">typeof</span> <span class="nx">obj</span> <span class="o">is</span> <span class="s1">&#39;undefined&#39;</span></pre></div> </td> </tr> <tr id="section-88"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-88">#</a> </div> <h2>Utility Functions</h2> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-89"> <td class="docs"> <div class="octowrap"> <a class="octothorpe" href="#section-89">#</a> </div> <p>Run Underscore.js in noConflict mode, returning the <code>_</code> variable to its
previous owner. Returns a reference to the Underscore object.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">_.noConflict: </span><span class="o">-&gt;</span>
<span class="nv">root._: </span><span class="nx">previousUnderscore</span>
View
36 documentation/index.html.erb
@@ -129,7 +129,7 @@ alert reverse '.eeffoC yrT'</textarea></div>
<p>
<b>Latest Version:</b>
- <a href="http://github.com/jashkenas/coffee-script/tarball/0.5.6">0.5.6</a>
+ <a href="http://github.com/jashkenas/coffee-script/tarball/0.6.0">0.6.0</a>
</p>
<h2>
@@ -170,12 +170,12 @@ alert reverse '.eeffoC yrT'</textarea></div>
</p>
<p>
- To install, first make sure you have a working version of
- <a href="http://nodejs.org/">Node.js</a> version 0.1.33 or higher.
+ To install, first make sure you have a working copy of the latest tagged version of
+ <a href="http://nodejs.org/">Node.js</a>, currently <b>0.1.33</b> or higher.
Then clone the CoffeeScript
<a href="http://github.com/jashkenas/coffee-script">source repository</a>
from GitHub, or download the latest
- release: <a href="http://github.com/jashkenas/coffee-script/tarball/0.5.6">0.5.6</a>.
+ release: <a href="http://github.com/jashkenas/coffee-script/tarball/0.6.0">0.6.0</a>.
To install the CoffeeScript compiler system-wide
under <tt>/usr/local</tt>, open the directory and run:
</p>
@@ -638,6 +638,10 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
is converted into a call against the immediate ancestor's method of the same name.
</p>
<%= code_for('prototypes', '"one_two".dasherize()') %>
+ <p>
+ Finally, you may assign Class-level (static) properties within a class
+ definition by using<br /><tt>@property: value</tt>
+ </p>
<p>
<span id="pattern_matching" class="bookmark"></span>
@@ -856,20 +860,40 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
<li>
<b>defunkt</b>'s <a href="http://github.com/defunkt/coffee-mode">CoffeeScript Major Mode</a>
&mdash; a Emacs major mode that provides syntax highlighting, indentation
- support, and some bonus commands. (For Vim and TextMate highlighters,
- see the <tt>extras</tt> directory of the main repository.)
+ support, and some bonus commands.
+ </li>
+ <li>
+ <b>jashkenas</b>'s <a href="http://github.com/jashkenas/coffee-script-tmbundle">CoffeeScript TextMate Bundle</a>
+ &mdash; which provides syntax highlighting, snippet expansion, and the
+ ability to run bits of CoffeeScript from within TextMate itself.
+ </li>
+ <li>
+ <b>kchmck</b>'s <a href="http://github.com/kchmck/vim-coffee-script">Vim CoffeeScript</a>
+ &mdash; which adds Vim syntax highlighting and indentation support.
</li>
<li>
<b>mattly</b>'s <a href="http://github.com/mattly/rack-coffee">rack-coffee</a>
&mdash; a small Rack middleware for serving CoffeeScript files as
compiled JavaScript on the fly.
</li>
+ <li>
+ <b>jnicklas</b>'s <a href="http://github.com/jnicklas/bistro_car">BistroCar</a>
+ &mdash; a plugin that serves and bundles CoffeeScript from within your
+ Rails application.
+ </li>
</ul>
<h2>
<span id="change_log" class="bookmark"></span>
Change Log
</h2>
+
+ <p>
+ <b class="header" style="margin-top: 20px;">0.6.0</b>
+ Trailing commas are now allowed, a-la Python. Static
+ properties may be assigned directly within class definitions,
+ using <tt>@property</tt> notation.
+ </p>
<p>
<b class="header" style="margin-top: 20px;">0.5.6</b>
View
18 documentation/js/array_comprehensions.js
@@ -2,20 +2,20 @@
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, food, lunch, roid, roid2;
// Eat lunch.
lunch = (function() {
- _a = []; _b = ['toast', 'cheese', 'wine'];
- for (_c = 0, _d = _b.length; _c < _d; _c++) {
- food = _b[_c];
+ _a = []; _c = ['toast', 'cheese', 'wine'];
+ for (_b = 0, _d = _c.length; _b < _d; _b++) {
+ food = _c[_b];
_a.push(eat(food));
}
return _a;
}).call(this);
// Naive collision detection.
- _e = asteroids;
- for (_f = 0, _g = _e.length; _f < _g; _f++) {
- roid = _e[_f];
- _h = asteroids;
- for (_i = 0, _j = _h.length; _i < _j; _i++) {
- roid2 = _h[_i];
+ _f = asteroids;
+ for (_e = 0, _g = _f.length; _e < _g; _e++) {
+ roid = _f[_e];
+ _i = asteroids;
+ for (_h = 0, _j = _i.length; _h < _j; _h++) {
+ roid2 = _i[_h];
if (roid !== roid2) {
if (roid.overlaps(roid2)) {
roid.explode();
View
9 documentation/js/binding.js
@@ -1,11 +1,12 @@
(function(){
var get_source, url;
- url = "documentation/coffee/binding.coffee";
- get_source = (function(func, obj, args) {
+ var __slice = Array.prototype.slice, __bind = function(func, obj, args) {
return function() {
- return func.apply(obj, args.concat(Array.prototype.slice.call(arguments, 0)));
+ return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);
};
- }(jQuery.get, jQuery, [url]));
+ };
+ url = "documentation/coffee/binding.coffee";
+ get_source = __bind(jQuery.get, jQuery, [url]);
get_source(function(response) {
return alert(response);
});
View
6 documentation/js/cake_tasks.js
@@ -1,9 +1,9 @@
(function(){
task('test', 'run each of the unit tests', function() {
var _a, _b, _c, _d, test;
- _a = []; _b = test_files;
- for (_c = 0, _d = _b.length; _c < _d; _c++) {
- test = _b[_c];
+ _a = []; _c = test_files;
+ for (_b = 0, _d = _c.length; _b < _d; _b++) {
+ test = _c[_b];
_a.push(fs.readFile(test, function(err, code) {
return eval(coffee.compile(code));
}));
View
14 documentation/js/fat_arrow.js
@@ -1,15 +1,15 @@
(function(){
var Account;
+ var __slice = Array.prototype.slice, __bind = function(func, obj, args) {
+ return function() {
+ return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);
+ };
+ };
Account = function Account(customer, cart) {
this.customer = customer;
this.cart = cart;
- return $('.shopping_cart').bind('click', (function(__this) {
- var __func = function(event) {
+ return $('.shopping_cart').bind('click', __bind(function(event) {
return this.customer.purchase(this.cart);
- };
- return (function() {
- return __func.apply(__this, arguments);
- });
- })(this));
+ }, this));
};
})();
View
9 documentation/js/overview.js
@@ -1,5 +1,6 @@
(function(){
var _a, _b, _c, _d, cubed_list, list, math, num, number, opposite_day, race, square;
+ var __slice = Array.prototype.slice;
// Assignment:
number = 42;
opposite_day = true;
@@ -24,7 +25,7 @@
// Splats:
race = function race(winner) {
var runners;
- runners = Array.prototype.slice.call(arguments, 1, arguments.length - 0);
+ runners = __slice.call(arguments, 1, arguments.length - 0);
return print(winner, runners);
};
// Existence:
@@ -33,9 +34,9 @@
}
// Array comprehensions:
cubed_list = (function() {
- _a = []; _b = list;
- for (_c = 0, _d = _b.length; _c < _d; _c++) {
- num = _b[_c];
+ _a = []; _c = list;
+ for (_b = 0, _d = _c.length; _b < _d; _b++) {
+ num = _c[_b];
_a.push(math.cube(num));
}
return _a;
View
3  documentation/js/patterns_and_splats.js
@@ -1,8 +1,9 @@
(function(){
var _a, close, contents, open, tag;
+ var __slice = Array.prototype.slice;
tag = "<impossible>";
_a = tag.split("");
open = _a[0];
- contents = Array.prototype.slice.call(_a, 1, _a.length - 1);
+ contents = __slice.call(_a, 1, _a.length - 1);
close = _a[_a.length - 1];
})();
View
16 documentation/js/range_comprehensions.js
@@ -1,21 +1,21 @@
(function(){
- var _a, _b, _c, _d, _e, countdown, egg_delivery, num;
+ var _a, _b, _c, _d, countdown, egg_delivery, num;
countdown = (function() {
- _a = []; _d = 10; _e = 1;
- for (_c = 0, num = _d; (_d <= _e ? num <= _e : num >= _e); (_d <= _e ? num += 1 : num -= 1), _c++) {
+ _a = []; _c = 10; _d = 1;
+ for (_b = 0, num = _c; (_c <= _d ? num <= _d : num >= _d); (_c <= _d ? num += 1 : num -= 1), _b++) {
_a.push(num);
}
return _a;
}).call(this);
egg_delivery = function egg_delivery() {
- var _f, _g, _h, _i, _j, dozen_eggs, i;
- _f = []; _i = 0; _j = eggs.length;
- for (_h = 0, i = _i; (_i <= _j ? i < _j : i > _j); (_i <= _j ? i += 12 : i -= 12), _h++) {
- _f.push((function() {
+ var _e, _f, _g, _h, dozen_eggs, i;
+ _e = []; _g = 0; _h = eggs.length;
+ for (_f = 0, i = _g; (_g <= _h ? i < _h : i > _h); (_g <= _h ? i += 12 : i -= 12), _f++) {
+ _e.push((function() {
dozen_eggs = eggs.slice(i, i + 12);
return deliver(new egg_carton(dozen));
}).call(this));
}
- return _f;
+ return _e;
};
})();
View
3  documentation/js/splats.js
@@ -1,9 +1,10 @@
(function(){
var award_medals, contenders, gold, silver, the_field;
+ var __slice = Array.prototype.slice;
gold = (silver = (the_field = "unknown"));
award_medals = function award_medals(first, second) {
var rest;
- rest = Array.prototype.slice.call(arguments, 2, arguments.length - 0);
+ rest = __slice.call(arguments, 2, arguments.length - 0);
gold = first;
silver = second;
the_field = rest;
View
16 examples/underscore.coffee
@@ -71,7 +71,7 @@
# Current version.
- _.VERSION: '0.6.0'
+ _.VERSION: '1.0.2'
# Collection Functions
@@ -422,9 +422,10 @@
# Extend a given object with all of the properties in a source object.
- _.extend: (destination, source) ->
- (destination[key]: val) for key, val of source
- destination
+ _.extend: (obj) ->
+ for source in _.rest(arguments)
+ (obj[key]: val) for key, val of source
+ obj
# Create a (shallow-cloned) duplicate of an object.
@@ -472,7 +473,7 @@
# Different object sizes?
return false if aKeys.length isnt bKeys.length
# Recursive comparison of contents.
- (return false) for key, val of a when !_.isEqual(val, b[key])
+ (return false) for key, val of a when !(key in b) or !_.isEqual(val, b[key])
true
@@ -488,12 +489,11 @@
# Is a given value an array?
- _.isArray: nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift)
+ _.isArray: nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift and not obj.callee)
# Is a given variable an arguments object?
- _.isArguments: (obj) -> obj and _.isNumber(obj.length) and not obj.concat and
- not obj.substr and not obj.apply and not propertyIsEnumerable.call(obj, 'length')
+ _.isArguments: (obj) -> obj and obj.callee
# Is the given value a function?
View
16 extras/EXTRAS
@@ -5,19 +5,3 @@ CoffeeScript compiler. To use it in the browser, include the script after any
inline script tags of type "text/coffeescript" on the page. It will compile
and evaluate all of the scripts in order.
-
-This folder also includes a CoffeeScript syntax highlighter for Vim.
-To install, copy "coffee.vim" into the "syntax" directory of
-your vim72, and enable it in either of the following two ways:
-
- * Manually, by running `:set syntax=coffee`
-
- * Or automatically, by creating a "filetype.vim" file within "~/.vim", which
- contains something along these lines:
-
- if exists("did_load_filetypes")
- finish
- end
- augroup filetypedetect
- au! BufRead,BufNewFile *.coffee setfiletype coffee
- augroup END
View
2  extras/coffee-script.js
1 addition, 1 deletion not shown
View
117 extras/coffee.vim
@@ -1,117 +0,0 @@
-" Vim syntax file
-" Language: CoffeeScript
-" Maintainer: Jeff Olson <olson.jeffery@gmail.com>
-" URL: http://github.com/olsonjeffery
-" Changes: (jro) initial port from javascript
-" Last Change: 2006 Jun 19
-" Adaptation of javascript.vim syntax file (distro'd w/ vim72),
-" maintained by Claudio Fleiner <claudio@fleiner.com>
-" with updates from Scott Shattuck (ss) <ss@technicalpursuit.com>
-
-if !exists("main_syntax")
- if version < 600
- syntax clear
- elseif exists("b:current_syntax")
- finish
- endif
- let main_syntax = 'coffee'
-endif
-
-syn case ignore
-
-syn match coffeeLineComment "#.*" contains=@Spell,CoffeeCommentTodo
-syn match coffeeSpecial "\\\d\d\d\|\\."
-syn region coffeeStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=coffeeSpecial,@htmlPreproc
-syn region coffeeStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=coffeeSpecial,@htmlPreproc
-
-syn match coffeeSpecialCharacter "'\\.'"
-syn match coffeeNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
-syn region coffeeRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
-
-syn match coffeeFunctionParams "([^)]*)\s*->"
-syn match coffeeBindFunctionParams "([^)]*)\s*=>"
-syn match coffeePrototypeAccess "::"
-syn match coffeeBindFunction "=[1]>[1]"
-syn match coffeeFunction "->"
-
-syn keyword coffeeExtends extends
-syn keyword coffeeConditional if else switch then not
-syn keyword coffeeRepeat while for in of
-syn keyword coffeeBranch break continue
-syn keyword coffeeOperator delete instanceof typeof
-syn keyword coffeeType Array Boolean Date Function Number Object String RegExp
-syn keyword coffeeStatement return with
-syn keyword coffeeBoolean true false
-syn keyword coffeeNull null undefined
-syn keyword coffeeIdentifier arguments this var
-syn keyword coffeeLabel case default
-syn keyword coffeeException try catch finally throw
-syn keyword coffeeMessage alert confirm prompt status
-syn keyword coffeeGlobal self window top parent
-syn keyword coffeeMember document event location
-syn keyword coffeeDeprecated escape unescape
-syn keyword coffeeReserved abstract boolean byte char class const debugger double enum export final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
-
-syn sync fromstart
-syn sync maxlines=100
-
-if main_syntax == "coffee"
- syn sync ccomment coffeeComment
-endif
-
-" Define the default highlighting.
-" For version 5.7 and earlier: only when not done already
-" For version 5.8 and later: only when an item doesn't have highlighting yet
-if version >= 508 || !exists("did_coffee_syn_inits")
- if version < 508
- let did_coffee_syn_inits = 1
- command -nargs=+ HiLink hi link <args>
- else
- command -nargs=+ HiLink hi def link <args>
- endif
- HiLink coffeePrototypeAccess Keyword
- HiLink coffeeExtends Keyword
- HiLink coffeeLineComment Comment
- HiLink coffeeSpecial Special
- HiLink coffeeStringS String
- HiLink coffeeStringD String
- HiLink coffeeCharacter Character
- HiLink coffeeSpecialCharacter coffeeSpecial
- HiLink coffeeNumber coffeeValue
- HiLink coffeeConditional Conditional
- HiLink coffeeRepeat Repeat
- HiLink coffeeBranch Conditional
- HiLink coffeeOperator Operator
- HiLink coffeeType Type
- HiLink coffeeStatement Statement
- HiLink coffeeBindFunctionParams Function
- HiLink coffeeFunctionParams Function
- HiLink coffeeFunction Function
- HiLink coffeeBindFunction Function
- HiLink coffeeBraces Function
- HiLink coffeeError Error
- HiLink coffeeScrParenError coffeeError
- HiLink coffeeNull Keyword
- HiLink coffeeBoolean Boolean
- HiLink coffeeRegexpString String
-
- HiLink coffeeIdentifier Identifier
- HiLink coffeeLabel Label
- HiLink coffeeException Exception
- HiLink coffeeMessage Keyword
- HiLink coffeeGlobal Keyword
- HiLink coffeeMember Keyword
- HiLink coffeeDeprecated Exception
- HiLink coffeeReserved Keyword
- HiLink coffeeDebug Debug
- HiLink coffeeConstant Label
-
- delcommand HiLink
-endif
-
-let b:current_syntax = "coffee"
-if main_syntax == 'coffee'
- unlet main_syntax
-endif
-
-" vim: ts=8
View
154 index.html
@@ -115,7 +115,7 @@
<p>
<b>Latest Version:</b>
- <a href="http://github.com/jashkenas/coffee-script/tarball/0.5.6">0.5.6</a>
+ <a href="http://github.com/jashkenas/coffee-script/tarball/0.6.0">0.6.0</a>
</p>
<h2>
@@ -155,6 +155,7 @@
<span class="Comment"><span class="Comment">#</span> Array comprehensions:</span>
cubed_list<span class="Keyword">:</span> math.cube num <span class="Keyword">for</span> num <span class="Keyword">in</span> list
</pre><pre class="idle"><span class="Storage">var</span> _a, _b, _c, _d, cubed_list, list, math, num, number, opposite_day, race, square;
+<span class="Storage">var</span> __slice <span class="Keyword">=</span> <span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice;
<span class="Comment"><span class="Comment">//</span> Assignment:</span>
number <span class="Keyword">=</span> <span class="Number">42</span>;
opposite_day <span class="Keyword">=</span> <span class="BuiltInConstant">true</span>;
@@ -179,7 +180,7 @@
<span class="Comment"><span class="Comment">//</span> Splats:</span>
race <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">race</span>(<span class="FunctionArgument">winner</span>) {
<span class="Storage">var</span> runners;
- runners <span class="Keyword">=</span> <span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">1</span>, arguments.<span class="LibraryConstant">length</span> <span class="Keyword">-</span> <span class="Number">0</span>);
+ runners <span class="Keyword">=</span> __slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">1</span>, arguments.<span class="LibraryConstant">length</span> <span class="Keyword">-</span> <span class="Number">0</span>);
<span class="Keyword">return</span> <span class="LibraryFunction">print</span>(winner, runners);
};
<span class="Comment"><span class="Comment">//</span> Existence:</span>
@@ -188,14 +189,15 @@
}
<span class="Comment"><span class="Comment">//</span> Array comprehensions:</span>
cubed_list <span class="Keyword">=</span> (<span class="Storage">function</span>() {
- _a <span class="Keyword">=</span> []; _b <span class="Keyword">=</span> list;
- <span class="Keyword">for</span> (_c <span class="Keyword">=</span> <span class="Number">0</span>, _d <span class="Keyword">=</span> _b.<span class="LibraryConstant">length</span>; _c <span class="Keyword">&lt;</span> _d; _c<span class="Keyword">++</span>) {
- num <span class="Keyword">=</span> _b[_c];
+ _a <span class="Keyword">=</span> []; _c <span class="Keyword">=</span> list;
+ <span class="Keyword">for</span> (_b <span class="Keyword">=</span> <span class="Number">0</span>, _d <span class="Keyword">=</span> _c.<span class="LibraryConstant">length</span>; _b <span class="Keyword">&lt;</span> _d; _b<span class="Keyword">++</span>) {
+ num <span class="Keyword">=</span> _c[_b];
_a.<span class="LibraryFunction">push</span>(math.cube(num));
}
<span class="Keyword">return</span> _a;
}).<span class="LibraryFunction">call</span>(<span class="Variable">this</span>);
</pre><button onclick='javascript: var _a, _b, _c, _d, cubed_list, list, math, num, number, opposite_day, race, square;
+var __slice = Array.prototype.slice;
// Assignment:
number = 42;
opposite_day = true;
@@ -220,7 +222,7 @@
// Splats:
race = function race(winner) {
var runners;
- runners = Array.prototype.slice.call(arguments, 1, arguments.length - 0);
+ runners = __slice.call(arguments, 1, arguments.length - 0);
return print(winner, runners);
};
// Existence:
@@ -229,9 +231,9 @@
}
// Array comprehensions:
cubed_list = (function() {
- _a = []; _b = list;
- for (_c = 0, _d = _b.length; _c < _d; _c++) {
- num = _b[_c];
+ _a = []; _c = list;
+ for (_b = 0, _d = _c.length; _b < _d; _b++) {
+ num = _c[_b];
_a.push(math.cube(num));
}
return _a;
@@ -267,12 +269,12 @@
</p>
<p>
- To install, first make sure you have a working version of
- <a href="http://nodejs.org/">Node.js</a> version 0.1.33 or higher.
+ To install, first make sure you have a working copy of the latest tagged version of
+ <a href="http://nodejs.org/">Node.js</a>, currently <b>0.1.33</b> or higher.
Then clone the CoffeeScript
<a href="http://github.com/jashkenas/coffee-script">source repository</a>
from GitHub, or download the latest
- release: <a href="http://github.com/jashkenas/coffee-script/tarball/0.5.6">0.5.6</a>.
+ release: <a href="http://github.com/jashkenas/coffee-script/tarball/0.6.0">0.6.0</a>.
To install the CoffeeScript compiler system-wide
under <tt>/usr/local</tt>, open the directory and run:
</p>
@@ -717,10 +719,11 @@
alert <span class="String"><span class="String">&quot;</span>Silver: <span class="String">&quot;</span></span> <span class="Keyword">+</span> silver
alert <span class="String"><span class="String">&quot;</span>The Field: <span class="String">&quot;</span></span> <span class="Keyword">+</span> the_field
</pre><pre class="idle"><span class="Storage">var</span> award_medals, contenders, gold, silver, the_field;
+<span class="Storage">var</span> __slice <span class="Keyword">=</span> <span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice;
gold <span class="Keyword">=</span> (silver <span class="Keyword">=</span> (the_field <span class="Keyword">=</span> <span class="String"><span class="String">&quot;</span>unknown<span class="String">&quot;</span></span>));
award_medals <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">award_medals</span>(<span class="FunctionArgument">first, second</span>) {
<span class="Storage">var</span> rest;
- rest <span class="Keyword">=</span> <span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">2</span>, arguments.<span class="LibraryConstant">length</span> <span class="Keyword">-</span> <span class="Number">0</span>);
+ rest <span class="Keyword">=</span> __slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">2</span>, arguments.<span class="LibraryConstant">length</span> <span class="Keyword">-</span> <span class="Number">0</span>);
gold <span class="Keyword">=</span> first;
silver <span class="Keyword">=</span> second;
the_field <span class="Keyword">=</span> rest;
@@ -732,10 +735,11 @@
<span class="LibraryFunction">alert</span>(<span class="String"><span class="String">&quot;</span>Silver: <span class="String">&quot;</span></span> <span class="Keyword">+</span> silver);
<span class="LibraryFunction">alert</span>(<span class="String"><span class="String">&quot;</span>The Field: <span class="String">&quot;</span></span> <span class="Keyword">+</span> the_field);
</pre><button onclick='javascript: var award_medals, contenders, gold, silver, the_field;
+var __slice = Array.prototype.slice;
gold = (silver = (the_field = "unknown"));
award_medals = function award_medals(first, second) {
var rest;
- rest = Array.prototype.slice.call(arguments, 2, arguments.length - 0);
+ rest = __slice.call(arguments, 2, arguments.length - 0);
gold = first;
silver = second;
the_field = rest;
@@ -834,20 +838,20 @@
</pre><pre class="idle"><span class="Storage">var</span> _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, food, lunch, roid, roid2;
<span class="Comment"><span class="Comment">//</span> Eat lunch.</span>
lunch <span class="Keyword">=</span> (<span class="Storage">function</span>() {
- _a <span class="Keyword">=</span> []; _b <span class="Keyword">=</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>];
- <span class="Keyword">for</span> (_c <span class="Keyword">=</span> <span class="Number">0</span>, _d <span class="Keyword">=</span> _b.<span class="LibraryConstant">length</span>; _c <span class="Keyword">&lt;</span> _d; _c<span class="Keyword">++</span>) {
- food <span class="Keyword">=</span> _b[_c];
+ _a <span class="Keyword">=</span> []; _c <span class="Keyword">=</span> [<span class="String"><span class="String">'</span>toast<span class="String">'</span></span>, <span class="String"><span class="String">'</span>cheese<span class="String">'</span></span>, <span class="String"><span class="String">'</span>wine<span class="String">'</span></span>];
+ <span class="Keyword">for</span> (_b <span class="Keyword">=</span> <span class="Number">0</span>, _d <span class="Keyword">=</span> _c.<span class="LibraryConstant">length</span>; _b <span class="Keyword">&lt;</span> _d; _b<span class="Keyword">++</span>) {
+ food <span class="Keyword">=</span> _c[_b];
_a.<span class="LibraryFunction">push</span>(eat(food));
}
<span class="Keyword">return</span> _a;
}).<span class="LibraryFunction">call</span>(<span class="Variable">this</span>);
<span class="Comment"><span class="Comment">//</span> Naive collision detection.</span>
-_e <span class="Keyword">=</span> asteroids;
-<span class="Keyword">for</span> (_f <span class="Keyword">=</span> <span class="Number">0</span>, _g <span class="Keyword">=</span> _e.<span class="LibraryConstant">length</span>; _f <span class="Keyword">&lt;</span> _g; _f<span class="Keyword">++</span>) {
- roid <span class="Keyword">=</span> _e[_f];
- _h <span class="Keyword">=</span> asteroids;
- <span class="Keyword">for</span> (_i <span class="Keyword">=</span> <span class="Number">0</span>, _j <span class="Keyword">=</span> _h.<span class="LibraryConstant">length</span>; _i <span class="Keyword">&lt;</span> _j; _i<span class="Keyword">++</span>) {
- roid2 <span class="Keyword">=</span> _h[_i];
+_f <span class="Keyword">=</span> asteroids;
+<span class="Keyword">for</span> (_e <span class="Keyword">=</span> <span class="Number">0</span>, _g <span class="Keyword">=</span> _f.<span class="LibraryConstant">length</span>; _e <span class="Keyword">&lt;</span> _g; _e<span class="Keyword">++</span>) {
+ roid <span class="Keyword">=</span> _f[_e];
+ _i <span class="Keyword">=</span> asteroids;
+ <span class="Keyword">for</span> (_h <span class="Keyword">=</span> <span class="Number">0</span>, _j <span class="Keyword">=</span> _i.<span class="LibraryConstant">length</span>; _h <span class="Keyword">&lt;</span> _j; _h<span class="Keyword">++</span>) {
+ roid2 <span class="Keyword">=</span> _i[_h];
<span class="Keyword">if</span> (roid <span class="Keyword">!</span><span class="Keyword">==</span> roid2) {
<span class="Keyword">if</span> (roid.overlaps(roid2)) {
roid.explode();
@@ -868,43 +872,43 @@
<span class="Keyword">for</span> i <span class="Keyword">in</span> [<span class="Number">0</span>...eggs.length] <span class="Keyword">by</span> <span class="Number">12</span>
dozen_eggs<span class="Keyword">:</span> eggs[i...i<span class="Keyword">+</span><span class="Number">12</span>]
deliver <span class="Keyword">new</span> <span class="TypeName">egg_carton</span>(dozen)
-</pre><pre class="idle"><span class="Storage">var</span> _a, _b, _c, _d, _e, countdown, egg_delivery, num;
+</pre><pre class="idle"><span class="Storage">var</span> _a, _b, _c, _d, countdown, egg_delivery, num;
countdown <span class="Keyword">=</span> (<span class="Storage">function</span>() {
- _a <span class="Keyword">=</span> []; _d <span class="Keyword">=</span> <span class="Number">10</span>; _e <span class="Keyword">=</span> <span class="Number">1</span>;
- <span class="Keyword">for</span> (_c <span class="Keyword">=</span> <span class="Number">0</span>, num <span class="Keyword">=</span> _d; (_d <span class="Keyword">&lt;=</span> _e ? num <span class="Keyword">&lt;=</span> _e : num <span class="Keyword">&gt;=</span> _e); (_d <span class="Keyword">&lt;=</span> _e ? num <span class="Keyword">+</span><span class="Keyword">=</span> <span class="Number">1</span> : num <span class="Keyword">-</span><span class="Keyword">=</span> <span class="Number">1</span>), _c<span class="Keyword">++</span>) {
+ _a <span class="Keyword">=</span> []; _c <span class="Keyword">=</span> <span class="Number">10</span>; _d <span class="Keyword">=</span> <span class="Number">1</span>;
+ <span class="Keyword">for</span> (_b <span class="Keyword">=</span> <span class="Number">0</span>, num <span class="Keyword">=</span> _c; (_c <span class="Keyword">&lt;=</span> _d ? num <span class="Keyword">&lt;=</span> _d : num <span class="Keyword">&gt;=</span> _d); (_c <span class="Keyword">&lt;=</span> _d ? num <span class="Keyword">+</span><span class="Keyword">=</span> <span class="Number">1</span> : num <span class="Keyword">-</span><span class="Keyword">=</span> <span class="Number">1</span>), _b<span class="Keyword">++</span>) {
_a.<span class="LibraryFunction">push</span>(num);
}
<span class="Keyword">return</span> _a;
}).<span class="LibraryFunction">call</span>(<span class="Variable">this</span>);
egg_delivery <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">egg_delivery</span>() {
- <span class="Storage">var</span> _f, _g, _h, _i, _j, dozen_eggs, i;
- _f <span class="Keyword">=</span> []; _i <span class="Keyword">=</span> <span class="Number">0</span>; _j <span class="Keyword">=</span> eggs.<span class="LibraryConstant">length</span>;
- <span class="Keyword">for</span> (_h <span class="Keyword">=</span> <span class="Number">0</span>, i <span class="Keyword">=</span> _i; (_i <span class="Keyword">&lt;=</span> _j ? i <span class="Keyword">&lt;</span> _j : i <span class="Keyword">&gt;</span> _j); (_i <span class="Keyword">&lt;=</span> _j ? i <span class="Keyword">+</span><span class="Keyword">=</span> <span class="Number">12</span> : i <span class="Keyword">-</span><span class="Keyword">=</span> <span class="Number">12</span>), _h<span class="Keyword">++</span>) {
- _f.<span class="LibraryFunction">push</span>((<span class="Storage">function</span>() {
+ <span class="Storage">var</span> _e, _f, _g, _h, dozen_eggs, i;
+ _e <span class="Keyword">=</span> []; _g <span class="Keyword">=</span> <span class="Number">0</span>; _h <span class="Keyword">=</span> eggs.<span class="LibraryConstant">length</span>;
+ <span class="Keyword">for</span> (_f <span class="Keyword">=</span> <span class="Number">0</span>, i <span class="Keyword">=</span> _g; (_g <span class="Keyword">&lt;=</span> _h ? i <span class="Keyword">&lt;</span> _h : i <span class="Keyword">&gt;</span> _h); (_g <span class="Keyword">&lt;=</span> _h ? i <span class="Keyword">+</span><span class="Keyword">=</span> <span class="Number">12</span> : i <span class="Keyword">-</span><span class="Keyword">=</span> <span class="Number">12</span>), _f<span class="Keyword">++</span>) {
+ _e.<span class="LibraryFunction">push</span>((<span class="Storage">function</span>() {
dozen_eggs <span class="Keyword">=</span> eggs.<span class="LibraryFunction">slice</span>(i, i <span class="Keyword">+</span> <span class="Number">12</span>);
<span class="Keyword">return</span> deliver(<span class="Keyword">new</span> <span class="TypeName">egg_carton</span>(dozen));
}).<span class="LibraryFunction">call</span>(<span class="Variable">this</span>));
}
- <span class="Keyword">return</span> _f;
+ <span class="Keyword">return</span> _e;
};
-</pre><button onclick='javascript: var _a, _b, _c, _d, _e, countdown, egg_delivery, num;
+</pre><button onclick='javascript: var _a, _b, _c, _d, countdown, egg_delivery, num;
countdown = (function() {
- _a = []; _d = 10; _e = 1;
- for (_c = 0, num = _d; (_d <= _e ? num <= _e : num >= _e); (_d <= _e ? num += 1 : num -= 1), _c++) {
+ _a = []; _c = 10; _d = 1;
+ for (_b = 0, num = _c; (_c <= _d ? num <= _d : num >= _d); (_c <= _d ? num += 1 : num -= 1), _b++) {
_a.push(num);
}
return _a;
}).call(this);
egg_delivery = function egg_delivery() {
- var _f, _g, _h, _i, _j, dozen_eggs, i;
- _f = []; _i = 0; _j = eggs.length;
- for (_h = 0, i = _i; (_i <= _j ? i < _j : i > _j); (_i <= _j ? i += 12 : i -= 12), _h++) {
- _f.push((function() {
+ var _e, _f, _g, _h, dozen_eggs, i;
+ _e = []; _g = 0; _h = eggs.length;
+ for (_f = 0, i = _g; (_g <= _h ? i < _h : i > _h); (_g <= _h ? i += 12 : i -= 12), _f++) {
+ _e.push((function() {
dozen_eggs = eggs.slice(i, i + 12);
return deliver(new egg_carton(dozen));
}).call(this));
}
- return _f;
+ return _e;
};
;alert(countdown);'>run: countdown</button><br class='clear' /></div>
<p>
@@ -1303,6 +1307,10 @@
return this.replace(/_/g, "-");
};
;alert("one_two".dasherize());'>run: "one_two".dasherize()</button><br class='clear' /></div>
+ <p>
+ Finally, you may assign Class-level (static) properties within a class
+ definition by using<br /><tt>@property: value</tt>
+ </p>
<p>
<span id="pattern_matching" class="bookmark"></span>
@@ -1419,16 +1427,18 @@
</pre><pre class="idle"><span class="Storage">var</span> _a, close, contents, open, tag;
+<span class="Storage">var</span> __slice <span class="Keyword">=</span> <span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice;
tag <span class="Keyword">=</span> <span class="String"><span class="String">&quot;</span>&lt;impossible&gt;<span class="String">&quot;</span></span>;
_a <span class="Keyword">=</span> tag.<span class="LibraryFunction">split</span>(<span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span>);
open <span class="Keyword">=</span> _a[<span class="Number">0</span>];
-contents <span class="Keyword">=</span> <span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice.<span class="LibraryFunction">call</span>(_a, <span class="Number">1</span>, _a.<span class="LibraryConstant">length</span> <span class="Keyword">-</span> <span class="Number">1</span>);
+contents <span class="Keyword">=</span> __slice.<span class="LibraryFunction">call</span>(_a, <span class="Number">1</span>, _a.<span class="LibraryConstant">length</span> <span class="Keyword">-</span> <span class="Number">1</span>);
close <span class="Keyword">=</span> _a[_a.<span class="LibraryConstant">length</span> <span class="Keyword">-</span> <span class="Number">1</span>];
</pre><button onclick='javascript: var _a, close, contents, open, tag;
+var __slice = Array.prototype.slice;
tag = "<impossible>";
_a = tag.split("");
open = _a[0];
-contents = Array.prototype.slice.call(_a, 1, _a.length - 1);
+contents = __slice.call(_a, 1, _a.length - 1);
close = _a[_a.length - 1];
;alert(contents.join(""));'>run: contents.join("")</button><br class='clear' /></div>
@@ -1457,17 +1467,17 @@
$(<span class="String"><span class="String">'</span>.shopping_cart<span class="String">'</span></span>).bind <span class="String"><span class="String">'</span>click<span class="String">'</span></span>, <span class="FunctionArgument">(</span><span class="FunctionArgument">event</span><span class="FunctionArgument">)</span> <span class="Storage">=&gt;</span>
<span class="Variable">@customer</span>.purchase <span class="Variable">@cart</span>
</pre><pre class="idle"><span class="Storage">var</span> Account;
+<span class="Storage">var</span> __slice <span class="Keyword">=</span> <span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice, <span class="FunctionName">__bind</span> = <span class="Storage">function</span>(<span class="FunctionArgument">func, obj, args</span>) {
+ <span class="Keyword">return</span> <span class="Storage">function</span>() {
+ <span class="Keyword">return</span> func.<span class="LibraryFunction">apply</span>(obj <span class="Keyword">||</span> {}, args ? args.<span class="LibraryFunction">concat</span>(__slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">0</span>)) : arguments);
+ };
+};
Account <span class="Keyword">=</span> <span class="Storage">function</span> <span class="FunctionName">Account</span>(<span class="FunctionArgument">customer, cart</span>) {
<span class="Variable">this</span>.customer <span class="Keyword">=</span> customer;
<span class="Variable">this</span>.cart <span class="Keyword">=</span> cart;
- <span class="Keyword">return</span> <span class="Keyword">$</span>(<span class="String"><span class="String">'</span>.shopping_cart<span class="String">'</span></span>).bind(<span class="String"><span class="String">'</span>click<span class="String">'</span></span>, (<span class="Storage">function</span>(__this) {
- <span class="Storage">var</span> <span class="FunctionName">__func</span> = <span class="Storage">function</span>(<span class="FunctionArgument">event</span>) {
+ <span class="Keyword">return</span> <span class="Keyword">$</span>(<span class="String"><span class="String">'</span>.shopping_cart<span class="String">'</span></span>).bind(<span class="String"><span class="String">'</span>click<span class="String">'</span></span>, __bind(<span class="Storage">function</span>(<span class="LibraryClassType">event</span>) {
<span class="Keyword">return</span> <span class="Variable">this</span>.customer.purchase(<span class="Variable">this</span>.cart);
- };
- <span class="Keyword">return</span> (<span class="Storage">function</span>() {
- <span class="Keyword">return</span> __func.<span class="LibraryFunction">apply</span>(__this, arguments);
- });
- })(<span class="Variable">this</span>));
+ }, <span class="Variable">this</span>));
};
</pre><br class='clear' /></div>
<p>
@@ -1489,22 +1499,24 @@
get_source <span class="FunctionArgument">(</span><span class="FunctionArgument">response</span><span class="FunctionArgument">)</span> <span class="Storage">-&gt;</span> alert response
</pre><pre class="idle"><span class="Storage">var</span> get_source, url;
-url <span class="Keyword">=</span> <span class="String"><span class="String">&quot;</span>documentation/coffee/binding.coffee<span class="String">&quot;</span></span>;
-get_source <span class="Keyword">=</span> (<span class="Storage">function</span>(func, obj, args) {
+<span class="Storage">var</span> __slice <span class="Keyword">=</span> <span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice, <span class="FunctionName">__bind</span> = <span class="Storage">function</span>(<span class="FunctionArgument">func, obj, args</span>) {
<span class="Keyword">return</span> <span class="Storage">function</span>() {
- <span class="Keyword">return</span> func.<span class="LibraryFunction">apply</span>(obj, args.<span class="LibraryFunction">concat</span>(<span class="LibraryClassType">Array</span>.<span class="LibraryConstant">prototype</span>.slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">0</span>)));
+ <span class="Keyword">return</span> func.<span class="LibraryFunction">apply</span>(obj <span class="Keyword">||</span> {}, args ? args.<span class="LibraryFunction">concat</span>(__slice.<span class="LibraryFunction">call</span>(arguments, <span class="Number">0</span>)) : arguments);
};
-}(jQuery.get, jQuery, [url]));
+};
+url <span class="Keyword">=</span> <span class="String"><span class="String">&quot;</span>documentation/coffee/binding.coffee<span class="String">&quot;</span></span>;
+get_source <span class="Keyword">=</span> __bind(jQuery.get, jQuery, [url]);
get_source(<span class="Storage">function</span>(response) {
<span class="Keyword">return</span> <span class="LibraryFunction">alert</span>(response);
});
</pre><button onclick='javascript: var get_source, url;
-url = "documentation/coffee/binding.coffee";
-get_source = (function(func, obj, args) {
+var __slice = Array.prototype.slice, __bind = function(func, obj, args) {
return function() {
- return func.apply(obj, args.concat(Array.prototype.slice.call(arguments, 0)));
+ return func.apply(obj || {}, args ? args.concat(__slice.call(arguments, 0)) : arguments);
};
-}(jQuery.get, jQuery, [url]));
+};
+url = "documentation/coffee/binding.coffee";
+get_source = __bind(jQuery.get, jQuery, [url]);
get_source(function(response) {
return alert(response);
});
@@ -1726,9 +1738,9 @@
fs.readFile test, <span class="FunctionArgument">(</span><span class="FunctionArgument">err, code</span><span class="FunctionArgument">)</span> <span class="Storage">-&gt;</span> eval coffee.compile code
</pre><pre class="idle">task(<span class="String"><span class="String">'</span>test<span class="String">'</span></span>, <span class="String"><span class="String">'</span>run each of the unit tests<span class="String">'</span></span>, <span class="Storage">function</span>() {
<span class="Storage">var</span> _a, _b, _c, _d, test;
- _a <span class="Keyword">=</span> []; _b <span class="Keyword">=</span> test_files;
- <span class="Keyword">for</span> (_c <span class="Keyword">=</span> <span class="Number">0</span>, _d <span class="Keyword">=</span> _b.<span class="LibraryConstant">length</span>; _c <span class="Keyword">&lt;</span> _d; _c<span class="Keyword">++</span>) {
- test <span class="Keyword">=</span> _b[_c];
+ _a <span class="Keyword">=</span> []; _c <span class="Keyword">=</span> test_files;
+ <span class="Keyword">for</span> (_b <span class="Keyword">=</span> <span class="Number">0</span>, _d <span class="Keyword">=</span> _c.<span class="LibraryConstant">length</span>; _b <span class="Keyword">&lt;</span> _d; _b<span class="Keyword">++</span>) {
+ test <span class="Keyword">=</span> _c[_b];
_a.<span class="LibraryFunction">push</span>(fs.readFile(test, <span class="Storage">function</span>(err, code) {
<span class="Keyword">return</span> <span class="LibraryFunction">eval</span>(coffee.<span class="LibraryFunction">compile</span>(code));
}));
@@ -1796,20 +1808,40 @@
<li>
<b>defunkt</b>'s <a href="http://github.com/defunkt/coffee-mode">CoffeeScript Major Mode</a>
&mdash; a Emacs major mode that provides syntax highlighting, indentation
- support, and some bonus commands. (For Vim and TextMate highlighters,
- see the <tt>extras</tt> directory of the main repository.)
+ support, and some bonus commands.
+ </li>
+ <li>
+ <b>jashkenas</b>'s <a href="http://github.com/jashkenas/coffee-script-tmbundle">CoffeeScript TextMate Bundle</a>
+ &mdash; which provides syntax highlighting, snippet expansion, and the
+ ability to run bits of CoffeeScript from within TextMate itself.
+ </li>
+ <li>
+ <b>kchmck</b>'s <a href="http://github.com/kchmck/vim-coffee-script">Vim CoffeeScript</a>
+ &mdash; which adds Vim syntax highlighting and indentation support.
</li>
<li>
<b>mattly</b>'s <a href="http://github.com/mattly/rack-coffee">rack-coffee</a>
&mdash; a small Rack middleware for serving CoffeeScript files as
compiled JavaScript on the fly.
</li>
+ <li>
+ <b>jnicklas</b>'s <a href="http://github.com/jnicklas/bistro_car">BistroCar</a>
+ &mdash; a plugin that serves and bundles CoffeeScript from within your
+ Rails application.
+ </li>
</ul>
<h2>
<span id="change_log" class="bookmark"></span>
Change Log
</h2>
+
+ <p>
+ <b class="header" style="margin-top: 20px;">0.6.0</b>
+ Trailing commas are now allowed, a-la Python. Static
+ properties may be assigned directly within class definitions,
+ using <tt>@property</tt> notation.
+ </p>
<p>
<b class="header" style="margin-top: 20px;">0.5.6</b>
View
2  lib/coffee-script.js
@@ -23,7 +23,7 @@
helpers = this.helpers;
}
// The current CoffeeScript version number.
- exports.VERSION = '0.5.6';
+ exports.VERSION = '0.6.0';
// Instantiate a Lexer for our use here.
lexer = new Lexer();
// Compile a string of CoffeeScript code to JavaScript, using the Coffee/Jison
View
2  package.json
@@ -3,5 +3,5 @@
"description": "Unfancy JavaScript",
"keywords": ["javascript", "language"],
"author": "Jeremy Ashkenas",
- "version": "0.5.6"
+ "version": "0.6.0"
}
View
2  src/coffee-script.coffee
@@ -22,7 +22,7 @@ else
helpers: this.helpers
# The current CoffeeScript version number.
-exports.VERSION: '0.5.6'
+exports.VERSION: '0.6.0'
# Instantiate a Lexer for our use here.
lexer: new Lexer()
Please sign in to comment.
Something went wrong with that request. Please try again.