mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
CoffeeScript 0.6.0 is on the books.
This commit is contained in:
parent
59ae79d8fb
commit
c067808b54
20 changed files with 203 additions and 258 deletions
20
README
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)
|
||||
|
|
@ -16,7 +16,7 @@ execute all scripts present in <code>text/coffeescript</code> tags.</p>
|
|||
<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">'0.5.6'</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">'0.6.0'</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">-></span>
|
||||
<span class="nv">options: </span><span class="o">or</span> <span class="p">{}</span>
|
||||
<span class="k">try</span>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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>
|
||||
— 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>
|
||||
— 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>
|
||||
— 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>
|
||||
— 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>
|
||||
— 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>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
}));
|
||||
|
|
|
@ -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));
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
})();
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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
|
154
index.html
154
index.html
|
@ -115,7 +115,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>
|
||||
|
@ -155,6 +155,7 @@ alert <span class="String"><span class="String">"</span>I knew it!<span cla
|
|||
<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 @@ math <span class="Keyword">=</span> {
|
|||
<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 @@ race <span class="Keyword">=</span> <span class="Storage">function</span> <span
|
|||
}
|
||||
<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"><</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"><</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 @@ math = {
|
|||
// 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 @@ if ((typeof elvis !== "undefined" && elvis !== null)) {
|
|||
}
|
||||
// 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 @@ cubed_list = (function() {
|
|||
</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">"</span>Gold: <span class="
|
|||
alert <span class="String"><span class="String">"</span>Silver: <span class="String">"</span></span> <span class="Keyword">+</span> silver
|
||||
alert <span class="String"><span class="String">"</span>The Field: <span class="String">"</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">"</span>unknown<span class="String">"</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 @@ award_medals.<span class="LibraryFunction">apply</span>(<span class="Variable">t
|
|||
<span class="LibraryFunction">alert</span>(<span class="String"><span class="String">"</span>Silver: <span class="String">"</span></span> <span class="Keyword">+</span> silver);
|
||||
<span class="LibraryFunction">alert</span>(<span class="String"><span class="String">"</span>The Field: <span class="String">"</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 @@ lunch<span class="Keyword">:</span> eat food <span class="Keyword">for</span> fo
|
|||
</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"><</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"><</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"><</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"><</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"><</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"><</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 @@ _e <span class="Keyword">=</span> asteroids;
|
|||
<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"><=</span> _e ? num <span class="Keyword"><=</span> _e : num <span class="Keyword">>=</span> _e); (_d <span class="Keyword"><=</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"><=</span> _d ? num <span class="Keyword"><=</span> _d : num <span class="Keyword">>=</span> _d); (_c <span class="Keyword"><=</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"><=</span> _j ? i <span class="Keyword"><</span> _j : i <span class="Keyword">></span> _j); (_i <span class="Keyword"><=</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"><=</span> _h ? i <span class="Keyword"><</span> _h : i <span class="Keyword">></span> _h); (_g <span class="Keyword"><=</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 @@ tom.move();
|
|||
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 @@ city = _c[1];
|
|||
|
||||
|
||||
</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">"</span><impossible><span class="String">"</span></span>;
|
||||
_a <span class="Keyword">=</span> tag.<span class="LibraryFunction">split</span>(<span class="String"><span class="String">"</span><span class="String">"</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 @@ close = _a[_a.length - 1];
|
|||
$(<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">=></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="Keyword">:</span> jQuery.get <span class="Keyword"><</
|
|||
|
||||
get_source <span class="FunctionArgument">(</span><span class="FunctionArgument">response</span><span class="FunctionArgument">)</span> <span class="Storage">-></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">"</span>documentation/coffee/binding.coffee<span class="String">"</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">"</span>documentation/coffee/binding.coffee<span class="String">"</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 @@ html <span class="Keyword">=</span> <span class="String"><span class="String">'<
|
|||
fs.readFile test, <span class="FunctionArgument">(</span><span class="FunctionArgument">err, code</span><span class="FunctionArgument">)</span> <span class="Storage">-></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"><</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"><</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 @@ html <span class="Keyword">=</span> <span class="String"><span class="String">'<
|
|||
<li>
|
||||
<b>defunkt</b>'s <a href="http://github.com/defunkt/coffee-mode">CoffeeScript Major Mode</a>
|
||||
— 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>
|
||||
— 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>
|
||||
— 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>
|
||||
— 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>
|
||||
— 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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
"description": "Unfancy JavaScript",
|
||||
"keywords": ["javascript", "language"],
|
||||
"author": "Jeremy Ashkenas",
|
||||
"version": "0.5.6"
|
||||
"version": "0.6.0"
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue