mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-13 08:47:55 -05:00
Compare commits
91 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f26d33d418 | ||
|
|
cea773ec81 | ||
|
|
98dd1bf8e8 | ||
|
|
56d75baac7 | ||
|
|
0872c3d13d | ||
|
|
5095e02b62 | ||
|
|
874628b1d0 | ||
|
|
ff9d5117f9 | ||
|
|
10aca2a38e | ||
|
|
2c4d437e98 | ||
|
|
c0c13c1977 | ||
|
|
6d9553a016 | ||
|
|
66716cd730 | ||
|
|
f588ecb288 | ||
|
|
dc3e177811 | ||
|
|
2eef667916 | ||
|
|
617a932e89 | ||
|
|
beac56d4d5 | ||
|
|
cc98e99070 | ||
|
|
93e4eeafed | ||
|
|
efdc67241a | ||
|
|
24e8f1c98f | ||
|
|
2d1a6fa6ec | ||
|
|
3d7d68a766 | ||
|
|
342b395b0a | ||
|
|
75ae45e2bb | ||
|
|
1f197fcc1b | ||
|
|
e339f5f2da | ||
|
|
c37f284771 | ||
|
|
585298dc17 | ||
|
|
2087923163 | ||
|
|
b58772e8a7 | ||
|
|
769f02ec05 | ||
|
|
52b1749d57 | ||
|
|
ba85a38cb0 | ||
|
|
c0d44b1abd | ||
|
|
0262322400 | ||
|
|
8e8f6d13bd | ||
|
|
b6667f0735 | ||
|
|
99ea1c7a39 | ||
|
|
27fd65390a | ||
|
|
79a6d89849 | ||
|
|
6fb5833843 | ||
|
|
5494ac13ee | ||
|
|
300faf401c | ||
|
|
f2c6066103 | ||
|
|
2a5320fd2b | ||
|
|
36695540fc | ||
|
|
fc0c4fdd5f | ||
|
|
ebc172d1ee | ||
|
|
4e6b6678f7 | ||
|
|
378a04e48c | ||
|
|
1e62781759 | ||
|
|
234adef20c | ||
|
|
8b463cd3ad | ||
|
|
ce10a463f3 | ||
|
|
140a73dca7 | ||
|
|
46d16b5c49 | ||
|
|
d16cf19c15 | ||
|
|
edbb9a77e7 | ||
|
|
cc4c3b2606 | ||
|
|
3a2888f97a | ||
|
|
bd17cc9b3c | ||
|
|
0a3e3639dc | ||
|
|
008bacf5d5 | ||
|
|
cc1b056b03 | ||
|
|
3548b4883e | ||
|
|
37a376497c | ||
|
|
83744917b0 | ||
|
|
a548b70e8c | ||
|
|
c8147c046a | ||
|
|
4a7497b451 | ||
|
|
06aa329596 | ||
|
|
9becb0e937 | ||
|
|
7f7765546f | ||
|
|
c7a365b6f1 | ||
|
|
84c125a71b | ||
|
|
06b74591e7 | ||
|
|
6645fbb895 | ||
|
|
c2758da9eb | ||
|
|
7a1c8fef0a | ||
|
|
71c59dddcc | ||
|
|
ef6f90753a | ||
|
|
50fff63252 | ||
|
|
8f5c77c3ce | ||
|
|
88529bc339 | ||
|
|
f37f9d1eda | ||
|
|
836175baab | ||
|
|
7395ac1d4f | ||
|
|
61988fe361 | ||
|
|
1301390087 |
50
README
50
README
@@ -1,50 +0,0 @@
|
||||
{
|
||||
} } {
|
||||
{ { } }
|
||||
} }{ {
|
||||
{ }{ } } _____ __ __
|
||||
{ }{ }{ { } / ____| / _|/ _|
|
||||
.- { { } { }} -. | | ___ | |_| |_ ___ ___
|
||||
( { } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|
||||
|`-..________ ..-'| | |___| (_) | | | || __/ __/
|
||||
| | \_____\___/|_| |_| \___|\___|
|
||||
| ;--.
|
||||
| (__ \ _____ _ _
|
||||
| | ) ) / ____| (_) | |
|
||||
| |/ / | (___ ___ _ __ _ _ __ | |_
|
||||
| ( / \___ \ / __| '__| | '_ \| __|
|
||||
| |/ ____) | (__| | | | |_) | |_
|
||||
| | |_____/ \___|_| |_| .__/ \__|
|
||||
`-.._________..-' | |
|
||||
|_|
|
||||
|
||||
|
||||
CoffeeScript is a little language that compiles into JavaScript.
|
||||
|
||||
If you have the Node Package Manager installed:
|
||||
npm install -g coffee-script
|
||||
(Leave off the -g if you don't wish to install globally.)
|
||||
|
||||
Or, if you don't wish to use npm:
|
||||
sudo bin/cake install
|
||||
|
||||
Execute a script:
|
||||
coffee /path/to/script.coffee
|
||||
|
||||
Compile a script:
|
||||
coffee -c /path/to/script.coffee
|
||||
|
||||
For documentation, usage, and examples, see:
|
||||
http://coffeescript.org/
|
||||
|
||||
To suggest a feature, report a bug, or general discussion:
|
||||
http://github.com/jashkenas/coffeescript/issues/
|
||||
|
||||
If you'd like to chat, drop by #coffeescript on Freenode IRC,
|
||||
or on webchat.freenode.net.
|
||||
|
||||
The source repository:
|
||||
git://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Top 100 contributors are listed here:
|
||||
http://github.com/jashkenas/coffeescript/contributors
|
||||
@@ -57,4 +57,6 @@ If you'd like to chat, drop by #coffeescript on Freenode IRC.
|
||||
|
||||
The source repository: https://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Changelog: http://coffeescript.org/#changelog
|
||||
|
||||
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "coffee-script",
|
||||
"version": "1.9.1",
|
||||
"version": "1.10.0",
|
||||
"main": [
|
||||
"lib/coffee-script/coffee-script.js"
|
||||
],
|
||||
|
||||
24
documentation/coffee/aliases.js
Normal file
24
documentation/coffee/aliases.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var volume, winner;
|
||||
|
||||
if (ignition === true) {
|
||||
launch();
|
||||
}
|
||||
|
||||
if (band !== SpinalTap) {
|
||||
volume = 10;
|
||||
}
|
||||
|
||||
if (answer !== false) {
|
||||
letTheWildRumpusBegin();
|
||||
}
|
||||
|
||||
if (car.speed < limit) {
|
||||
accelerate();
|
||||
}
|
||||
|
||||
if (pick === 47 || pick === 92 || pick === 13) {
|
||||
winner = true;
|
||||
}
|
||||
|
||||
print(inspect("My name is " + this.name));
|
||||
24
documentation/coffee/array_comprehensions.js
Normal file
24
documentation/coffee/array_comprehensions.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var courses, dish, food, foods, i, j, k, l, len, len1, len2, ref;
|
||||
|
||||
ref = ['toast', 'cheese', 'wine'];
|
||||
for (j = 0, len = ref.length; j < len; j++) {
|
||||
food = ref[j];
|
||||
eat(food);
|
||||
}
|
||||
|
||||
courses = ['greens', 'caviar', 'truffles', 'roast', 'cake'];
|
||||
|
||||
for (i = k = 0, len1 = courses.length; k < len1; i = ++k) {
|
||||
dish = courses[i];
|
||||
menu(i + 1, dish);
|
||||
}
|
||||
|
||||
foods = ['broccoli', 'spinach', 'chocolate'];
|
||||
|
||||
for (l = 0, len2 = foods.length; l < len2; l++) {
|
||||
food = foods[l];
|
||||
if (food !== 'chocolate') {
|
||||
eat(food);
|
||||
}
|
||||
}
|
||||
7
documentation/coffee/block_comment.js
Normal file
7
documentation/coffee/block_comment.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
|
||||
/*
|
||||
SkinnyMochaHalfCaffScript Compiler v1.0
|
||||
Released under the MIT License
|
||||
*/
|
||||
|
||||
14
documentation/coffee/cake_tasks.js
Normal file
14
documentation/coffee/cake_tasks.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var fs;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
option('-o', '--output [DIR]', 'directory for compiled code');
|
||||
|
||||
task('build:parser', 'rebuild the Jison parser', function(options) {
|
||||
var code, dir;
|
||||
require('jison');
|
||||
code = require('./lib/grammar').parser.generate();
|
||||
dir = options.output || 'lib';
|
||||
return fs.writeFile(dir + "/parser.js", code);
|
||||
});
|
||||
@@ -4,5 +4,3 @@ $ 'body'
|
||||
.fadeIn 'fast'
|
||||
.addClass '.active'
|
||||
.css 'background', 'white'
|
||||
|
||||
|
||||
|
||||
4
documentation/coffee/chaining.js
Normal file
4
documentation/coffee/chaining.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
$('body').click(function(e) {
|
||||
return $('.box').fadeIn('fast').addClass('.active');
|
||||
}).css('background', 'white');
|
||||
@@ -19,7 +19,3 @@ tom = new Horse "Tommy the Palomino"
|
||||
|
||||
sam.move()
|
||||
tom.move()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
57
documentation/coffee/classes.js
Normal file
57
documentation/coffee/classes.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var Animal, Horse, Snake, sam, tom,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
Animal = (function() {
|
||||
function Animal(name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
Animal.prototype.move = function(meters) {
|
||||
return alert(this.name + (" moved " + meters + "m."));
|
||||
};
|
||||
|
||||
return Animal;
|
||||
|
||||
})();
|
||||
|
||||
Snake = (function(superClass) {
|
||||
extend(Snake, superClass);
|
||||
|
||||
function Snake() {
|
||||
return Snake.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
Snake.prototype.move = function() {
|
||||
alert("Slithering...");
|
||||
return Snake.__super__.move.call(this, 5);
|
||||
};
|
||||
|
||||
return Snake;
|
||||
|
||||
})(Animal);
|
||||
|
||||
Horse = (function(superClass) {
|
||||
extend(Horse, superClass);
|
||||
|
||||
function Horse() {
|
||||
return Horse.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
Horse.prototype.move = function() {
|
||||
alert("Galloping...");
|
||||
return Horse.__super__.move.call(this, 45);
|
||||
};
|
||||
|
||||
return Horse;
|
||||
|
||||
})(Animal);
|
||||
|
||||
sam = new Snake("Sammy the Python");
|
||||
|
||||
tom = new Horse("Tommy the Palomino");
|
||||
|
||||
sam.move();
|
||||
|
||||
tom.move();
|
||||
@@ -1,5 +1,3 @@
|
||||
cholesterol = 127
|
||||
|
||||
healthy = 200 > cholesterol > 60
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/comparisons.js
Normal file
6
documentation/coffee/comparisons.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var cholesterol, healthy;
|
||||
|
||||
cholesterol = 127;
|
||||
|
||||
healthy = (200 > cholesterol && cholesterol > 60);
|
||||
@@ -7,6 +7,3 @@ else
|
||||
showIt()
|
||||
|
||||
date = if friday then sue else jill
|
||||
|
||||
|
||||
|
||||
|
||||
15
documentation/coffee/conditionals.js
Normal file
15
documentation/coffee/conditionals.js
Normal file
@@ -0,0 +1,15 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var date, mood;
|
||||
|
||||
if (singing) {
|
||||
mood = greatlyImproved;
|
||||
}
|
||||
|
||||
if (happy && knowsIt) {
|
||||
clapsHands();
|
||||
chaChaCha();
|
||||
} else {
|
||||
showIt();
|
||||
}
|
||||
|
||||
date = friday ? sue : jill;
|
||||
@@ -1,6 +1,5 @@
|
||||
class Person
|
||||
constructor: (options) ->
|
||||
{@name, @age, @height} = options
|
||||
|
||||
tim = new Person age: 4
|
||||
constructor: (options) ->
|
||||
{@name, @age, @height = 'average'} = options
|
||||
|
||||
tim = new Person name: 'Tim', age: 4
|
||||
|
||||
17
documentation/coffee/constructor_destructuring.js
Normal file
17
documentation/coffee/constructor_destructuring.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var Person, tim;
|
||||
|
||||
Person = (function() {
|
||||
function Person(options) {
|
||||
var ref;
|
||||
this.name = options.name, this.age = options.age, this.height = (ref = options.height) != null ? ref : 'average';
|
||||
}
|
||||
|
||||
return Person;
|
||||
|
||||
})();
|
||||
|
||||
tim = new Person({
|
||||
name: 'Tim',
|
||||
age: 4
|
||||
});
|
||||
@@ -1,8 +1,2 @@
|
||||
fill = (container, liquid = "coffee") ->
|
||||
"Filling the #{container} with #{liquid}..."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
9
documentation/coffee/default_args.js
Normal file
9
documentation/coffee/default_args.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var fill;
|
||||
|
||||
fill = function(container, liquid) {
|
||||
if (liquid == null) {
|
||||
liquid = "coffee";
|
||||
}
|
||||
return "Filling the " + container + " with " + liquid + "...";
|
||||
};
|
||||
12
documentation/coffee/do.js
Normal file
12
documentation/coffee/do.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var filename, fn, i, len;
|
||||
|
||||
fn = function(filename) {
|
||||
return fs.readFile(filename, function(err, contents) {
|
||||
return compile(filename, contents.toString());
|
||||
});
|
||||
};
|
||||
for (i = 0, len = list.length; i < len; i++) {
|
||||
filename = list[i];
|
||||
fn(filename);
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
hi = `function() {
|
||||
return [document.title, "Hello JavaScript"].join(": ");
|
||||
}`
|
||||
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/embedded.js
Normal file
6
documentation/coffee/embedded.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var hi;
|
||||
|
||||
hi = function() {
|
||||
return [document.title, "Hello JavaScript"].join(": ");
|
||||
};
|
||||
@@ -4,10 +4,3 @@ speed = 0
|
||||
speed ?= 15
|
||||
|
||||
footprints = yeti ? "bear"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
14
documentation/coffee/existence.js
Normal file
14
documentation/coffee/existence.js
Normal file
@@ -0,0 +1,14 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var footprints, solipsism, speed;
|
||||
|
||||
if ((typeof mind !== "undefined" && mind !== null) && (typeof world === "undefined" || world === null)) {
|
||||
solipsism = true;
|
||||
}
|
||||
|
||||
speed = 0;
|
||||
|
||||
if (speed == null) {
|
||||
speed = 15;
|
||||
}
|
||||
|
||||
footprints = typeof yeti !== "undefined" && yeti !== null ? yeti : "bear";
|
||||
@@ -2,6 +2,3 @@ text = "Every literary critic believes he will
|
||||
outwit history and have the last word"
|
||||
|
||||
[first, ..., last] = text.split " "
|
||||
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/expansion.js
Normal file
6
documentation/coffee/expansion.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var first, last, ref, text;
|
||||
|
||||
text = "Every literary critic believes he will outwit history and have the last word";
|
||||
|
||||
ref = text.split(" "), first = ref[0], last = ref[ref.length - 1];
|
||||
18
documentation/coffee/expressions.js
Normal file
18
documentation/coffee/expressions.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var eldest, grade;
|
||||
|
||||
grade = function(student) {
|
||||
if (student.excellentWork) {
|
||||
return "A+";
|
||||
} else if (student.okayStuff) {
|
||||
if (student.triedHard) {
|
||||
return "B";
|
||||
} else {
|
||||
return "B-";
|
||||
}
|
||||
} else {
|
||||
return "C";
|
||||
}
|
||||
};
|
||||
|
||||
eldest = 24 > 21 ? "Liz" : "Ike";
|
||||
@@ -1,3 +1 @@
|
||||
six = (one = 1) + (two = 2) + (three = 3)
|
||||
|
||||
|
||||
|
||||
4
documentation/coffee/expressions_assignment.js
Normal file
4
documentation/coffee/expressions_assignment.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var one, six, three, two;
|
||||
|
||||
six = (one = 1) + (two = 2) + (three = 3);
|
||||
11
documentation/coffee/expressions_comprehension.js
Normal file
11
documentation/coffee/expressions_comprehension.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var globals, name;
|
||||
|
||||
globals = ((function() {
|
||||
var results;
|
||||
results = [];
|
||||
for (name in window) {
|
||||
results.push(name);
|
||||
}
|
||||
return results;
|
||||
})()).slice(0, 10);
|
||||
@@ -4,4 +4,3 @@ alert(
|
||||
catch error
|
||||
"And the error is ... #{error}"
|
||||
)
|
||||
|
||||
|
||||
12
documentation/coffee/expressions_try.js
Normal file
12
documentation/coffee/expressions_try.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var error;
|
||||
|
||||
alert((function() {
|
||||
var error1;
|
||||
try {
|
||||
return nonexistent / void 0;
|
||||
} catch (error1) {
|
||||
error = error1;
|
||||
return "And the error is ... " + error;
|
||||
}
|
||||
})());
|
||||
@@ -2,5 +2,5 @@ Account = (customer, cart) ->
|
||||
@customer = customer
|
||||
@cart = cart
|
||||
|
||||
$('.shopping_cart').bind 'click', (event) =>
|
||||
$('.shopping_cart').on 'click', (event) =>
|
||||
@customer.purchase @cart
|
||||
12
documentation/coffee/fat_arrow.js
Normal file
12
documentation/coffee/fat_arrow.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var Account;
|
||||
|
||||
Account = function(customer, cart) {
|
||||
this.customer = customer;
|
||||
this.cart = cart;
|
||||
return $('.shopping_cart').on('click', (function(_this) {
|
||||
return function(event) {
|
||||
return _this.customer.purchase(_this.cart);
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
10
documentation/coffee/functions.js
Normal file
10
documentation/coffee/functions.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var cube, square;
|
||||
|
||||
square = function(x) {
|
||||
return x * x;
|
||||
};
|
||||
|
||||
cube = function(x) {
|
||||
return square(x) * x;
|
||||
};
|
||||
13
documentation/coffee/generators.js
Normal file
13
documentation/coffee/generators.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var perfectSquares;
|
||||
|
||||
perfectSquares = function*() {
|
||||
var num;
|
||||
num = 0;
|
||||
while (true) {
|
||||
num += 1;
|
||||
(yield num * num);
|
||||
}
|
||||
};
|
||||
|
||||
window.ps || (window.ps = perfectSquares());
|
||||
@@ -3,4 +3,3 @@ html = """
|
||||
cup of coffeescript
|
||||
</strong>
|
||||
"""
|
||||
|
||||
|
||||
4
documentation/coffee/heredocs.js
Normal file
4
documentation/coffee/heredocs.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var html;
|
||||
|
||||
html = "<strong>\n cup of coffeescript\n</strong>";
|
||||
@@ -7,5 +7,3 @@ OPERATOR = /// ^ (
|
||||
| \?\. # soak access
|
||||
| \.{2,3} # range or splat
|
||||
) ///
|
||||
|
||||
|
||||
|
||||
4
documentation/coffee/heregexes.js
Normal file
4
documentation/coffee/heregexes.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var OPERATOR;
|
||||
|
||||
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
|
||||
@@ -2,8 +2,3 @@ author = "Wittgenstein"
|
||||
quote = "A picture is a fact. -- #{ author }"
|
||||
|
||||
sentence = "#{ 22 / 7 } is a decent approximation of π"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8
documentation/coffee/interpolation.js
Normal file
8
documentation/coffee/interpolation.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var author, quote, sentence;
|
||||
|
||||
author = "Wittgenstein";
|
||||
|
||||
quote = "A picture is a fact. -- " + author;
|
||||
|
||||
sentence = (22 / 7) + " is a decent approximation of π";
|
||||
4
documentation/coffee/modulo.coffee
Normal file
4
documentation/coffee/modulo.coffee
Normal file
@@ -0,0 +1,4 @@
|
||||
-7 % 5 == -2 # The remainder of 7 / 5
|
||||
-7 %% 5 == 3 # n %% 5 is always between 0 and 4
|
||||
|
||||
tabs.selectTabAtIndex((tabs.currentIndex - count) %% tabs.length)
|
||||
8
documentation/coffee/modulo.js
Normal file
8
documentation/coffee/modulo.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var modulo = function(a, b) { return (+a % (b = +b) + b) % b; };
|
||||
|
||||
-7 % 5 === -2;
|
||||
|
||||
modulo(-7, 5) === 3;
|
||||
|
||||
tabs.selectTabAtIndex(modulo(tabs.currentIndex - count, tabs.length));
|
||||
@@ -3,7 +3,3 @@ weatherReport = (location) ->
|
||||
[location, 72, "Mostly Sunny"]
|
||||
|
||||
[city, temp, forecast] = weatherReport "Berkeley, CA"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8
documentation/coffee/multiple_return_values.js
Normal file
8
documentation/coffee/multiple_return_values.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var city, forecast, ref, temp, weatherReport;
|
||||
|
||||
weatherReport = function(location) {
|
||||
return [location, 72, "Mostly Sunny"];
|
||||
};
|
||||
|
||||
ref = weatherReport("Berkeley, CA"), city = ref[0], temp = ref[1], forecast = ref[2];
|
||||
18
documentation/coffee/object_comprehensions.js
Normal file
18
documentation/coffee/object_comprehensions.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var age, ages, child, yearsOld;
|
||||
|
||||
yearsOld = {
|
||||
max: 10,
|
||||
ida: 9,
|
||||
tim: 11
|
||||
};
|
||||
|
||||
ages = (function() {
|
||||
var results;
|
||||
results = [];
|
||||
for (child in yearsOld) {
|
||||
age = yearsOld[child];
|
||||
results.push(child + " is " + age);
|
||||
}
|
||||
return results;
|
||||
})();
|
||||
@@ -9,6 +9,3 @@ futurists =
|
||||
]
|
||||
|
||||
{poet: {name, address: [street, city]}} = futurists
|
||||
|
||||
|
||||
|
||||
|
||||
13
documentation/coffee/object_extraction.js
Normal file
13
documentation/coffee/object_extraction.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var city, futurists, name, ref, ref1, street;
|
||||
|
||||
futurists = {
|
||||
sculptor: "Umberto Boccioni",
|
||||
painter: "Vladimir Burliuk",
|
||||
poet: {
|
||||
name: "F.T. Marinetti",
|
||||
address: ["Via Roma 42R", "Bellagio, Italy 22021"]
|
||||
}
|
||||
};
|
||||
|
||||
ref = futurists.poet, name = ref.name, (ref1 = ref.address, street = ref1[0], city = ref1[1]);
|
||||
@@ -15,5 +15,3 @@ kids =
|
||||
sister:
|
||||
name: "Ida"
|
||||
age: 9
|
||||
|
||||
|
||||
|
||||
22
documentation/coffee/objects_and_arrays.js
Normal file
22
documentation/coffee/objects_and_arrays.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var bitlist, kids, singers, song;
|
||||
|
||||
song = ["do", "re", "mi", "fa", "so"];
|
||||
|
||||
singers = {
|
||||
Jagger: "Rock",
|
||||
Elvis: "Roll"
|
||||
};
|
||||
|
||||
bitlist = [1, 0, 1, 0, 0, 1, 1, 1, 0];
|
||||
|
||||
kids = {
|
||||
brother: {
|
||||
name: "Max",
|
||||
age: 11
|
||||
},
|
||||
sister: {
|
||||
name: "Ida",
|
||||
age: 9
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,3 @@
|
||||
$('.account').attr class: 'active'
|
||||
|
||||
log object.class
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/objects_reserved.js
Normal file
6
documentation/coffee/objects_reserved.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
$('.account').attr({
|
||||
"class": 'active'
|
||||
});
|
||||
|
||||
log(object["class"]);
|
||||
45
documentation/coffee/overview.js
Normal file
45
documentation/coffee/overview.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var cubes, list, math, num, number, opposite, race, square,
|
||||
slice = [].slice;
|
||||
|
||||
number = 42;
|
||||
|
||||
opposite = true;
|
||||
|
||||
if (opposite) {
|
||||
number = -42;
|
||||
}
|
||||
|
||||
square = function(x) {
|
||||
return x * x;
|
||||
};
|
||||
|
||||
list = [1, 2, 3, 4, 5];
|
||||
|
||||
math = {
|
||||
root: Math.sqrt,
|
||||
square: square,
|
||||
cube: function(x) {
|
||||
return x * square(x);
|
||||
}
|
||||
};
|
||||
|
||||
race = function() {
|
||||
var runners, winner;
|
||||
winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
return print(winner, runners);
|
||||
};
|
||||
|
||||
if (typeof elvis !== "undefined" && elvis !== null) {
|
||||
alert("I knew it!");
|
||||
}
|
||||
|
||||
cubes = (function() {
|
||||
var i, len, results;
|
||||
results = [];
|
||||
for (i = 0, len = list.length; i < len; i++) {
|
||||
num = list[i];
|
||||
results.push(math.cube(num));
|
||||
}
|
||||
return results;
|
||||
})();
|
||||
@@ -2,8 +2,3 @@ theBait = 1000
|
||||
theSwitch = 0
|
||||
|
||||
[theBait, theSwitch] = [theSwitch, theBait]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8
documentation/coffee/parallel_assignment.js
Normal file
8
documentation/coffee/parallel_assignment.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var ref, theBait, theSwitch;
|
||||
|
||||
theBait = 1000;
|
||||
|
||||
theSwitch = 0;
|
||||
|
||||
ref = [theSwitch, theBait], theBait = ref[0], theSwitch = ref[1];
|
||||
@@ -1,9 +1,3 @@
|
||||
tag = "<impossible>"
|
||||
|
||||
[open, contents..., close] = tag.split("")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7
documentation/coffee/patterns_and_splats.js
Normal file
7
documentation/coffee/patterns_and_splats.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var close, contents, i, open, ref, tag,
|
||||
slice = [].slice;
|
||||
|
||||
tag = "<impossible>";
|
||||
|
||||
ref = tag.split(""), open = ref[0], contents = 3 <= ref.length ? slice.call(ref, 1, i = ref.length - 1) : (i = 1, []), close = ref[i++];
|
||||
@@ -1,3 +1,2 @@
|
||||
String::dasherize = ->
|
||||
this.replace /_/g, "-"
|
||||
|
||||
|
||||
4
documentation/coffee/prototypes.js
vendored
Normal file
4
documentation/coffee/prototypes.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
String.prototype.dasherize = function() {
|
||||
return this.replace(/_/g, "-");
|
||||
};
|
||||
@@ -1,2 +1 @@
|
||||
countdown = (num for num in [10..1])
|
||||
|
||||
|
||||
11
documentation/coffee/range_comprehensions.js
Normal file
11
documentation/coffee/range_comprehensions.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var countdown, num;
|
||||
|
||||
countdown = (function() {
|
||||
var i, results;
|
||||
results = [];
|
||||
for (num = i = 10; i >= 1; num = --i) {
|
||||
results.push(num);
|
||||
}
|
||||
return results;
|
||||
})();
|
||||
12
documentation/coffee/scope.js
Normal file
12
documentation/coffee/scope.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var changeNumbers, inner, outer;
|
||||
|
||||
outer = 1;
|
||||
|
||||
changeNumbers = function() {
|
||||
var inner;
|
||||
inner = -1;
|
||||
return outer = 10;
|
||||
};
|
||||
|
||||
inner = changeNumbers();
|
||||
12
documentation/coffee/slices.js
Normal file
12
documentation/coffee/slices.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var copy, end, middle, numbers, start;
|
||||
|
||||
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
start = numbers.slice(0, 3);
|
||||
|
||||
middle = numbers.slice(3, -2);
|
||||
|
||||
end = numbers.slice(-2);
|
||||
|
||||
copy = numbers.slice(0);
|
||||
4
documentation/coffee/soaks.js
Normal file
4
documentation/coffee/soaks.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var ref, zip;
|
||||
|
||||
zip = typeof lottery.drawWinner === "function" ? (ref = lottery.drawWinner().address) != null ? ref.zipcode : void 0 : void 0;
|
||||
@@ -23,5 +23,3 @@ awardMedals contenders...
|
||||
alert "Gold: " + gold
|
||||
alert "Silver: " + silver
|
||||
alert "The Field: " + rest
|
||||
|
||||
|
||||
|
||||
23
documentation/coffee/splats.js
Normal file
23
documentation/coffee/splats.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var awardMedals, contenders, gold, rest, silver,
|
||||
slice = [].slice;
|
||||
|
||||
gold = silver = rest = "unknown";
|
||||
|
||||
awardMedals = function() {
|
||||
var first, others, second;
|
||||
first = arguments[0], second = arguments[1], others = 3 <= arguments.length ? slice.call(arguments, 2) : [];
|
||||
gold = first;
|
||||
silver = second;
|
||||
return rest = others;
|
||||
};
|
||||
|
||||
contenders = ["Michael Phelps", "Liu Xiang", "Yao Ming", "Allyson Felix", "Shawn Johnson", "Roman Sebrle", "Guo Jingjing", "Tyson Gay", "Asafa Powell", "Usain Bolt"];
|
||||
|
||||
awardMedals.apply(null, contenders);
|
||||
|
||||
alert("Gold: " + gold);
|
||||
|
||||
alert("Silver: " + silver);
|
||||
|
||||
alert("The Field: " + rest);
|
||||
@@ -1,7 +1,3 @@
|
||||
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
|
||||
numbers[3..6] = [-3, -4, -5, -6]
|
||||
|
||||
|
||||
|
||||
|
||||
6
documentation/coffee/splices.js
Normal file
6
documentation/coffee/splices.js
Normal file
@@ -0,0 +1,6 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var numbers, ref;
|
||||
|
||||
numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
[].splice.apply(numbers, [3, 4].concat(ref = [-3, -4, -5, -6])), ref;
|
||||
4
documentation/coffee/strings.js
Normal file
4
documentation/coffee/strings.js
Normal file
@@ -0,0 +1,4 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var mobyDick;
|
||||
|
||||
mobyDick = "Call me Ishmael. Some years ago -- never mind how long precisely -- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world...";
|
||||
24
documentation/coffee/switch.js
Normal file
24
documentation/coffee/switch.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
switch (day) {
|
||||
case "Mon":
|
||||
go(work);
|
||||
break;
|
||||
case "Tue":
|
||||
go(relax);
|
||||
break;
|
||||
case "Thu":
|
||||
go(iceFishing);
|
||||
break;
|
||||
case "Fri":
|
||||
case "Sat":
|
||||
if (day === bingoDay) {
|
||||
go(bingo);
|
||||
go(dancing);
|
||||
}
|
||||
break;
|
||||
case "Sun":
|
||||
go(church);
|
||||
break;
|
||||
default:
|
||||
go(work);
|
||||
}
|
||||
19
documentation/coffee/switch_with_no_expression.js
Normal file
19
documentation/coffee/switch_with_no_expression.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var grade, score;
|
||||
|
||||
score = 76;
|
||||
|
||||
grade = (function() {
|
||||
switch (false) {
|
||||
case !(score < 60):
|
||||
return 'F';
|
||||
case !(score < 70):
|
||||
return 'D';
|
||||
case !(score < 80):
|
||||
return 'C';
|
||||
case !(score < 90):
|
||||
return 'B';
|
||||
default:
|
||||
return 'A';
|
||||
}
|
||||
})();
|
||||
@@ -5,4 +5,3 @@ catch error
|
||||
print error
|
||||
finally
|
||||
cleanUp()
|
||||
|
||||
|
||||
12
documentation/coffee/try.js
Normal file
12
documentation/coffee/try.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var error, error1;
|
||||
|
||||
try {
|
||||
allHellBreaksLoose();
|
||||
catsAndDogsLivingTogether();
|
||||
} catch (error1) {
|
||||
error = error1;
|
||||
print(error);
|
||||
} finally {
|
||||
cleanUp();
|
||||
}
|
||||
22
documentation/coffee/while.js
Normal file
22
documentation/coffee/while.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var lyrics, num;
|
||||
|
||||
if (this.studyingEconomics) {
|
||||
while (supply > demand) {
|
||||
buy();
|
||||
}
|
||||
while (!(supply > demand)) {
|
||||
sell();
|
||||
}
|
||||
}
|
||||
|
||||
num = 6;
|
||||
|
||||
lyrics = (function() {
|
||||
var results;
|
||||
results = [];
|
||||
while (num -= 1) {
|
||||
results.push(num + " little monkeys, jumping on the bed. One fell out and bumped his head.");
|
||||
}
|
||||
return results;
|
||||
})();
|
||||
@@ -9,6 +9,7 @@ body {
|
||||
width: 950px;
|
||||
margin: 0;
|
||||
padding: 80px 0px 50px 50px;
|
||||
clear: both;
|
||||
}
|
||||
p, li {
|
||||
width: 625px;
|
||||
@@ -56,7 +57,7 @@ table.definitions {
|
||||
text-align: center;
|
||||
padding: 5px 20px;
|
||||
}
|
||||
code, pre, tt, textarea {
|
||||
code, pre, textarea {
|
||||
font-family: Monaco, Consolas, "Lucida Console", monospace;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
@@ -64,7 +65,7 @@ code, pre, tt, textarea {
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
tt {
|
||||
p > code, li > code {
|
||||
display: inline-block;
|
||||
background: #fff;
|
||||
border: 1px solid #dedede;
|
||||
@@ -111,9 +112,12 @@ div.code {
|
||||
float: left;
|
||||
width: 450px;
|
||||
background: #fff;
|
||||
border-left: 1px dotted #d0d0d0;
|
||||
margin: 10px 0 15px 3px;
|
||||
padding: 0 0 0 12px;
|
||||
border: 1px dotted #d0d0d0;
|
||||
border-top-width: 0;
|
||||
border-bottom-width: 0;
|
||||
border-right-width: 0;
|
||||
margin: 0 3px 15px 3px;
|
||||
padding: 10px 0 0 12px;
|
||||
}
|
||||
div.code pre:first-child {
|
||||
border-left: 0;
|
||||
@@ -134,7 +138,6 @@ div.code {
|
||||
height: 50px;
|
||||
min-width: 490px;
|
||||
left: 40px; right: 40px; top: 25px;
|
||||
padding-left: 252px;
|
||||
background: #eee;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#dadada));
|
||||
background: -moz-linear-gradient(top, #f8f8f8, #dadada);
|
||||
@@ -149,8 +152,9 @@ div.code {
|
||||
#logo {
|
||||
display: block;
|
||||
outline: none;
|
||||
position: absolute;
|
||||
top: 0px; left: 10px;
|
||||
float: left;
|
||||
width: 242px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
#logo img {
|
||||
margin: 5px 0 0 3px;
|
||||
@@ -221,6 +225,7 @@ div.code {
|
||||
display: block;
|
||||
}
|
||||
.navigation .contents.menu {
|
||||
z-index: 100;
|
||||
border-top: 0;
|
||||
-webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; border-top-left-radius: 0;
|
||||
-webkit-border-top-right-radius: 0; -moz-border-radius-topright: 0; border-top-right-radius: 0;
|
||||
@@ -377,3 +382,36 @@ div.code {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
@media (max-width: 820px) {
|
||||
.container {
|
||||
width: auto;
|
||||
padding: 1em;
|
||||
}
|
||||
p, li, table {
|
||||
width: auto;
|
||||
}
|
||||
#fadeout {
|
||||
display: none;
|
||||
}
|
||||
#flybar {
|
||||
position: static;
|
||||
height: auto;
|
||||
min-width: 245px;
|
||||
}
|
||||
#logo {
|
||||
float: none;
|
||||
}
|
||||
.navigation {
|
||||
float: none;
|
||||
border: none;
|
||||
}
|
||||
div.code pre, div.code textarea {
|
||||
border-left: none;
|
||||
border-top-width: 1px;
|
||||
width: auto;
|
||||
float: none;
|
||||
}
|
||||
div.code pre:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,8 +261,9 @@ This happens on page load.</p>
|
||||
<span class="hljs-keyword">for</span> script, i <span class="hljs-keyword">in</span> coffees
|
||||
<span class="hljs-keyword">do</span> <span class="hljs-function"><span class="hljs-params">(script, i)</span> -></span>
|
||||
options = <span class="hljs-attribute">literate</span>: script.type <span class="hljs-keyword">is</span> coffeetypes[<span class="hljs-number">1</span>]
|
||||
<span class="hljs-keyword">if</span> script.src
|
||||
CoffeeScript.load script.src,
|
||||
source = script.src <span class="hljs-keyword">or</span> script.getAttribute(<span class="hljs-string">'data-src'</span>)
|
||||
<span class="hljs-keyword">if</span> source
|
||||
CoffeeScript.load source,
|
||||
<span class="hljs-function"><span class="hljs-params">(param)</span> -></span>
|
||||
coffees[i] = param
|
||||
execute()
|
||||
|
||||
@@ -144,7 +144,7 @@ SourceMap = <span class="hljs-built_in">require</span> <span class="hljs-str
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.VERSION = <span class="hljs-string">'1.9.1'</span>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.VERSION = <span class="hljs-string">'1.10.0'</span>
|
||||
|
||||
<span class="hljs-built_in">exports</span>.FILE_EXTENSIONS = [<span class="hljs-string">'.coffee'</span>, <span class="hljs-string">'.litcoffee'</span>, <span class="hljs-string">'.coffee.md'</span>]</pre></div></div>
|
||||
|
||||
@@ -182,6 +182,7 @@ lexer/parser/compiler.</p>
|
||||
<span class="hljs-keyword">try</span>
|
||||
fn.call @, code, options
|
||||
<span class="hljs-keyword">catch</span> err
|
||||
<span class="hljs-keyword">throw</span> err <span class="hljs-keyword">if</span> <span class="hljs-keyword">typeof</span> code <span class="hljs-keyword">isnt</span> <span class="hljs-string">'string'</span> <span class="hljs-comment"># Support `CoffeeScript.nodes(tokens)`.</span>
|
||||
<span class="hljs-keyword">throw</span> helpers.updateSyntaxError err, code, options.filename</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -252,8 +253,22 @@ the same name.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> options.sourceMap
|
||||
<span class="hljs-keyword">if</span> fragment.locationData
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> options.sourceMap</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
</div>
|
||||
<p>Do not include empty, whitespace, or semicolon-only fragments.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> fragment.locationData <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> <span class="hljs-regexp">/^[;\s]*$/</span>.test fragment.code
|
||||
map.add(
|
||||
[fragment.locationData.first_line, fragment.locationData.first_column]
|
||||
[currentLine, currentColumn]
|
||||
@@ -268,11 +283,11 @@ the same name.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-8">
|
||||
<li id="section-9">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-8">¶</a>
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
</div>
|
||||
<p>Copy the code from each fragment into the final JavaScript.</p>
|
||||
|
||||
@@ -295,11 +310,11 @@ the same name.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-9">
|
||||
<li id="section-10">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-9">¶</a>
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
</div>
|
||||
<p>Tokenize a string of CoffeeScript code, and return the array of tokens.</p>
|
||||
|
||||
@@ -311,11 +326,11 @@ the same name.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-10">
|
||||
<li id="section-11">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-10">¶</a>
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
</div>
|
||||
<p>Parse a string of CoffeeScript code or an array of lexed tokens, and
|
||||
return the AST. You can then compile it by calling <code>.compile()</code> on the root,
|
||||
@@ -332,11 +347,11 @@ or traverse it by using <code>.traverseChildren()</code> with a callback.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-11">
|
||||
<li id="section-12">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-11">¶</a>
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
</div>
|
||||
<p>Compile and execute a string of CoffeeScript (on the server), correctly
|
||||
setting <code>__filename</code>, <code>__dirname</code>, and relative <code>require()</code>.</p>
|
||||
@@ -349,11 +364,11 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-12">
|
||||
<li id="section-13">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-12">¶</a>
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
</div>
|
||||
<p>Set the filename.</p>
|
||||
|
||||
@@ -365,11 +380,11 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-13">
|
||||
<li id="section-14">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-13">¶</a>
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
</div>
|
||||
<p>Clear the module cache.</p>
|
||||
|
||||
@@ -380,11 +395,11 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-14">
|
||||
<li id="section-15">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-14">¶</a>
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
</div>
|
||||
<p>Assign paths for node_modules loading</p>
|
||||
|
||||
@@ -399,11 +414,11 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-15">
|
||||
<li id="section-16">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-15">¶</a>
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
</div>
|
||||
<p>Compile.</p>
|
||||
|
||||
@@ -418,11 +433,11 @@ setting <code>__filename</code>, <code>__dirname</code>, and relative <code>requ
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-16">
|
||||
<li id="section-17">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-16">¶</a>
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
</div>
|
||||
<p>Compile and evaluate a string of CoffeeScript (in a Node.js-like environment).
|
||||
The CoffeeScript REPL uses this to run the input.</p>
|
||||
@@ -452,11 +467,11 @@ The CoffeeScript REPL uses this to run the input.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-17">
|
||||
<li id="section-18">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-17">¶</a>
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
</div>
|
||||
<p>define module/require only if they chose not to specify their own</p>
|
||||
|
||||
@@ -467,16 +482,17 @@ The CoffeeScript REPL uses this to run the input.</p>
|
||||
sandbox.<span class="hljs-built_in">module</span> = _module = <span class="hljs-keyword">new</span> Module(options.modulename || <span class="hljs-string">'eval'</span>)
|
||||
sandbox.<span class="hljs-built_in">require</span> = <span class="hljs-function"><span class="hljs-title">_require</span> = <span class="hljs-params">(path)</span> -></span> Module._load path, _module, <span class="hljs-literal">true</span>
|
||||
_module.filename = sandbox.__filename
|
||||
_require[r] = <span class="hljs-built_in">require</span>[r] <span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">isnt</span> <span class="hljs-string">'paths'</span></pre></div></div>
|
||||
<span class="hljs-keyword">for</span> r <span class="hljs-keyword">in</span> Object.getOwnPropertyNames <span class="hljs-built_in">require</span> <span class="hljs-keyword">when</span> r <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> [<span class="hljs-string">'paths'</span>, <span class="hljs-string">'arguments'</span>, <span class="hljs-string">'caller'</span>]
|
||||
_require[r] = <span class="hljs-built_in">require</span>[r]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-18">
|
||||
<li id="section-19">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-18">¶</a>
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
</div>
|
||||
<p>use the same hack node currently uses for their own REPL</p>
|
||||
|
||||
@@ -498,11 +514,11 @@ The CoffeeScript REPL uses this to run the input.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-19">
|
||||
<li id="section-20">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-19">¶</a>
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
</div>
|
||||
<p>Throw error with deprecation warning when depending upon implicit <code>require.extensions</code> registration</p>
|
||||
|
||||
@@ -526,11 +542,11 @@ The CoffeeScript REPL uses this to run the input.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-20">
|
||||
<li id="section-21">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-20">¶</a>
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
</div>
|
||||
<p>As the filename and code of a dynamically loaded file will be different
|
||||
from the original file compiled with CoffeeScript.run, add that
|
||||
@@ -545,11 +561,11 @@ information to error so it can be pretty-printed later.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-21">
|
||||
<li id="section-22">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-21">¶</a>
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
</div>
|
||||
<p>Instantiate a Lexer for our use here.</p>
|
||||
|
||||
@@ -560,11 +576,11 @@ information to error so it can be pretty-printed later.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-22">
|
||||
<li id="section-23">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-22">¶</a>
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
</div>
|
||||
<p>The real Lexer produces a generic stream of tokens. This object provides a
|
||||
thin wrapper around it, compatible with the Jison API. We can then pass it
|
||||
@@ -592,11 +608,11 @@ directly as a “Jison lexer”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-23">
|
||||
<li id="section-24">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-23">¶</a>
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
</div>
|
||||
<p>Make all the AST nodes visible to the parser.</p>
|
||||
|
||||
@@ -607,11 +623,11 @@ directly as a “Jison lexer”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-24">
|
||||
<li id="section-25">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-24">¶</a>
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
</div>
|
||||
<p>Override Jison’s default error handling function.</p>
|
||||
|
||||
@@ -622,11 +638,11 @@ directly as a “Jison lexer”.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-25">
|
||||
<li id="section-26">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-25">¶</a>
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
</div>
|
||||
<p>Disregard Jison’s message, it contains redundant line numer information.
|
||||
Disregard the token, we take its value directly from the lexer in case
|
||||
@@ -650,11 +666,11 @@ the error is caused by a generated token which might refer to its origin.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-26">
|
||||
<li id="section-27">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-26">¶</a>
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
</div>
|
||||
<p>The second argument has a <code>loc</code> property, which should have the location
|
||||
data for this token. Unfortunately, Jison seems to send an outdated <code>loc</code>
|
||||
@@ -668,11 +684,11 @@ from the lexer.</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-27">
|
||||
<li id="section-28">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-27">¶</a>
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
</div>
|
||||
<p>Based on <a href="http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js">http://v8.googlecode.com/svn/branches/bleeding_edge/src/messages.js</a>
|
||||
Modified to handle sourceMap</p>
|
||||
@@ -700,11 +716,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-28">
|
||||
<li id="section-29">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-28">¶</a>
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
</div>
|
||||
<p>Check for a sourceMap position</p>
|
||||
|
||||
@@ -745,11 +761,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-29">
|
||||
<li id="section-30">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-29">¶</a>
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
</div>
|
||||
<p>Map of filenames -> sourceMap object.</p>
|
||||
|
||||
@@ -760,11 +776,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-30">
|
||||
<li id="section-31">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-30">¶</a>
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
</div>
|
||||
<p>Generates the source map for a coffee file and stores it in the local cache variable.</p>
|
||||
|
||||
@@ -779,11 +795,11 @@ Modified to handle sourceMap</p>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="section-31">
|
||||
<li id="section-32">
|
||||
<div class="annotation">
|
||||
|
||||
<div class="pilwrap ">
|
||||
<a class="pilcrow" href="#section-31">¶</a>
|
||||
<a class="pilcrow" href="#section-32">¶</a>
|
||||
</div>
|
||||
<p>Based on <a href="http://goo.gl/ZTx1p">michaelficarra/CoffeeScriptRedux</a>
|
||||
NodeJS / V8 have no support for transforming positions in stack traces using
|
||||
|
||||
@@ -211,6 +211,7 @@ useWinPathSep = path.sep <span class="hljs-keyword">is</span> <span class="hljs
|
||||
[ <span class="hljs-string">'--no-header'</span>, <span class="hljs-string">'suppress the "Generated by" header'</span>]
|
||||
[<span class="hljs-string">'-o'</span>, <span class="hljs-string">'--output [DIR]'</span>, <span class="hljs-string">'set the output directory for compiled JavaScript'</span>]
|
||||
[<span class="hljs-string">'-p'</span>, <span class="hljs-string">'--print'</span>, <span class="hljs-string">'print out the compiled JavaScript'</span>]
|
||||
[<span class="hljs-string">'-r'</span>, <span class="hljs-string">'--require [MODULE*]'</span>, <span class="hljs-string">'require the given module before eval or REPL'</span>]
|
||||
[<span class="hljs-string">'-s'</span>, <span class="hljs-string">'--stdio'</span>, <span class="hljs-string">'listen for and compile scripts over stdio'</span>]
|
||||
[<span class="hljs-string">'-l'</span>, <span class="hljs-string">'--literate'</span>, <span class="hljs-string">'treat stdio as literate style coffee-script'</span>]
|
||||
[<span class="hljs-string">'-t'</span>, <span class="hljs-string">'--tokens'</span>, <span class="hljs-string">'print out the tokens that the lexer/rewriter produce'</span>]
|
||||
@@ -236,8 +237,7 @@ sources = []
|
||||
sourceCode = []
|
||||
notSources = {}
|
||||
watchedDirs = {}
|
||||
optionParser = <span class="hljs-literal">null</span>
|
||||
jsToSources = {}</pre></div></div>
|
||||
optionParser = <span class="hljs-literal">null</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -273,6 +273,8 @@ Many flags cause us to divert before compiling anything. Flags passed after
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> replCliOpts = <span class="hljs-attribute">useGlobal</span>: <span class="hljs-literal">yes</span>
|
||||
opts.prelude = makePrelude opts.<span class="hljs-built_in">require</span> <span class="hljs-keyword">if</span> opts.<span class="hljs-built_in">require</span>
|
||||
replCliOpts.prelude = opts.prelude
|
||||
<span class="hljs-keyword">return</span> forkNode() <span class="hljs-keyword">if</span> opts.nodejs
|
||||
<span class="hljs-keyword">return</span> usage() <span class="hljs-keyword">if</span> opts.help
|
||||
<span class="hljs-keyword">return</span> version() <span class="hljs-keyword">if</span> opts.version
|
||||
@@ -303,7 +305,14 @@ Many flags cause us to divert before compiling anything. Flags passed after
|
||||
'''</span>
|
||||
<span class="hljs-keyword">for</span> source <span class="hljs-keyword">in</span> opts.arguments
|
||||
source = path.resolve source
|
||||
compilePath source, <span class="hljs-literal">yes</span>, source</pre></div></div>
|
||||
compilePath source, <span class="hljs-literal">yes</span>, source
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">makePrelude</span> = <span class="hljs-params">(requires)</span> -></span>
|
||||
requires.map <span class="hljs-function"><span class="hljs-params">(<span class="hljs-built_in">module</span>)</span> -></span>
|
||||
[_, name, <span class="hljs-built_in">module</span>] = match <span class="hljs-keyword">if</span> match = <span class="hljs-built_in">module</span>.match(<span class="hljs-regexp">/^(.*)=(.*)$/</span>)
|
||||
name ||= helpers.baseFileName <span class="hljs-built_in">module</span>, <span class="hljs-literal">yes</span>, useWinPathSep
|
||||
<span class="hljs-string">"<span class="hljs-subst">#{name}</span> = require('<span class="hljs-subst">#{<span class="hljs-built_in">module</span>}</span>')"</span>
|
||||
.join <span class="hljs-string">';'</span></pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -395,6 +404,7 @@ requested options. If evaluating the script directly sets <code>__filename</code
|
||||
printLine CoffeeScript.nodes(t.input, t.options).toString().trim()
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.run
|
||||
CoffeeScript.register()
|
||||
CoffeeScript.eval opts.prelude, t.options <span class="hljs-keyword">if</span> opts.prelude
|
||||
CoffeeScript.run t.input, t.options
|
||||
<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> o.join <span class="hljs-keyword">and</span> t.file <span class="hljs-keyword">isnt</span> o.join
|
||||
t.input = helpers.invertLiterate t.input <span class="hljs-keyword">if</span> helpers.isLiterate file
|
||||
@@ -676,12 +686,6 @@ same directory as the <code>.js</code> file.</p>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-function"><span class="hljs-title">writeJs</span> = <span class="hljs-params">(base, sourcePath, js, jsPath, generatedSourceMap = <span class="hljs-literal">null</span>)</span> -></span>
|
||||
sourceMapPath = outputPath sourcePath, base, <span class="hljs-string">".js.map"</span>
|
||||
jsDir = path.dirname jsPath
|
||||
<span class="hljs-keyword">if</span> jsPath <span class="hljs-keyword">of</span> jsToSources
|
||||
printLine <span class="hljs-string">"Error: The two following source files have the same output file:"</span>
|
||||
printLine <span class="hljs-string">" "</span> + jsToSources[jsPath]
|
||||
printLine <span class="hljs-string">" "</span> + sourcePath
|
||||
process.exit <span class="hljs-number">1</span>
|
||||
jsToSources[jsPath] = sourcePath
|
||||
<span class="hljs-function"><span class="hljs-title">compile</span> = -></span>
|
||||
<span class="hljs-keyword">if</span> opts.compile
|
||||
js = <span class="hljs-string">' '</span> <span class="hljs-keyword">if</span> js.length <= <span class="hljs-number">0</span>
|
||||
@@ -832,7 +836,7 @@ the <code>node</code> binary, preserving the other options.</p>
|
||||
p = spawn process.execPath, nodeArgs.concat(args),
|
||||
<span class="hljs-attribute">cwd</span>: process.cwd()
|
||||
<span class="hljs-attribute">env</span>: process.env
|
||||
<span class="hljs-attribute">customFds</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
|
||||
<span class="hljs-attribute">stdio</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>]
|
||||
p.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function"><span class="hljs-params">(code)</span> -></span> process.exit code</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -532,16 +532,27 @@ the ordinary <strong>Assign</strong> is that these allow numbers and strings as
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-attribute">AssignObj</span>: [
|
||||
o <span class="hljs-string">'ObjAssignable'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>
|
||||
o <span class="hljs-string">'ObjAssignable : Expression'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value($<span class="hljs-number">1</span>)), $<span class="hljs-number">3</span>, <span class="hljs-string">'object'</span>
|
||||
o <span class="hljs-string">'ObjAssignable : Expression'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">3</span>, <span class="hljs-string">'object'</span>,
|
||||
<span class="hljs-attribute">operatorToken</span>: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'ObjAssignable :
|
||||
INDENT Expression OUTDENT'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value($<span class="hljs-number">1</span>)), $<span class="hljs-number">4</span>, <span class="hljs-string">'object'</span>
|
||||
INDENT Expression OUTDENT'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">4</span>, <span class="hljs-string">'object'</span>,
|
||||
<span class="hljs-attribute">operatorToken</span>: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'SimpleObjAssignable = Expression'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">3</span>, <span class="hljs-literal">null</span>,
|
||||
<span class="hljs-attribute">operatorToken</span>: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'SimpleObjAssignable =
|
||||
INDENT Expression OUTDENT'</span>,<span class="hljs-function"> -></span> <span class="hljs-keyword">new</span> Assign LOC(<span class="hljs-number">1</span>)(<span class="hljs-keyword">new</span> Value $<span class="hljs-number">1</span>), $<span class="hljs-number">4</span>, <span class="hljs-literal">null</span>,
|
||||
<span class="hljs-attribute">operatorToken</span>: LOC(<span class="hljs-number">2</span>)(<span class="hljs-keyword">new</span> Literal $<span class="hljs-number">2</span>)
|
||||
o <span class="hljs-string">'Comment'</span>
|
||||
]
|
||||
|
||||
<span class="hljs-attribute">ObjAssignable</span>: [
|
||||
<span class="hljs-attribute">SimpleObjAssignable</span>: [
|
||||
o <span class="hljs-string">'Identifier'</span>
|
||||
o <span class="hljs-string">'AlphaNumeric'</span>
|
||||
o <span class="hljs-string">'ThisProperty'</span>
|
||||
]
|
||||
|
||||
<span class="hljs-attribute">ObjAssignable</span>: [
|
||||
o <span class="hljs-string">'SimpleObjAssignable'</span>
|
||||
o <span class="hljs-string">'AlphaNumeric'</span>
|
||||
]</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -277,7 +277,7 @@ Handy for getting a list of <code>children</code> from the nodes.</p>
|
||||
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">exports</span>.flatten = <span class="hljs-function"><span class="hljs-title">flatten</span> = <span class="hljs-params">(array)</span> -></span>
|
||||
flattened = []
|
||||
<span class="hljs-keyword">for</span> element <span class="hljs-keyword">in</span> array
|
||||
<span class="hljs-keyword">if</span> element <span class="hljs-keyword">instanceof</span> Array
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-string">'[object Array]'</span> <span class="hljs-keyword">is</span> <span class="hljs-attribute">Object</span>::toString.call element
|
||||
flattened = flattened.concat flatten element
|
||||
<span class="hljs-keyword">else</span>
|
||||
flattened.push element
|
||||
@@ -583,7 +583,7 @@ it already.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> process?
|
||||
colorsEnabled = process.stdout.isTTY <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> process.env.NODE_DISABLE_COLORS
|
||||
colorsEnabled = process.stdout?.isTTY <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> process.env?.NODE_DISABLE_COLORS
|
||||
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-property">@colorful</span> ? colorsEnabled
|
||||
<span class="hljs-function"><span class="hljs-title">colorize</span> = <span class="hljs-params">(str)</span> -></span> <span class="hljs-string">"\x1B[1;31m<span class="hljs-subst">#{str}</span>\x1B[0m"</span>
|
||||
|
||||
@@ -216,6 +216,7 @@ it has consumed.</p>
|
||||
<span class="hljs-property">@indents</span> = [] <span class="hljs-comment"># The stack of all current indentation levels.</span>
|
||||
<span class="hljs-property">@ends</span> = [] <span class="hljs-comment"># The stack for pairing up tokens.</span>
|
||||
<span class="hljs-property">@tokens</span> = [] <span class="hljs-comment"># Stream of parsed tokens in the form `['TYPE', value, location data]`.</span>
|
||||
<span class="hljs-property">@seenFor</span> = <span class="hljs-literal">no</span> <span class="hljs-comment"># Used to recognize FORIN and FOROF tokens.</span>
|
||||
|
||||
<span class="hljs-property">@chunkLine</span> =
|
||||
opts.line <span class="hljs-keyword">or</span> <span class="hljs-number">0</span> <span class="hljs-comment"># The start line for the current @chunk.</span>
|
||||
@@ -403,7 +404,9 @@ though <code>is</code> means <code>===</code> otherwise.</p>
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"reserved word '<span class="hljs-subst">#{id}</span>'"</span>, <span class="hljs-attribute">length</span>: id.length
|
||||
|
||||
<span class="hljs-keyword">unless</span> forcedIdentifier
|
||||
id = COFFEE_ALIAS_MAP[id] <span class="hljs-keyword">if</span> id <span class="hljs-keyword">in</span> COFFEE_ALIASES
|
||||
<span class="hljs-keyword">if</span> id <span class="hljs-keyword">in</span> COFFEE_ALIASES
|
||||
alias = id
|
||||
id = COFFEE_ALIAS_MAP[id]
|
||||
tag = <span class="hljs-keyword">switch</span> id
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'!'</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'UNARY'</span>
|
||||
<span class="hljs-keyword">when</span> <span class="hljs-string">'=='</span>, <span class="hljs-string">'!='</span> <span class="hljs-keyword">then</span> <span class="hljs-string">'COMPARE'</span>
|
||||
@@ -413,6 +416,7 @@ though <code>is</code> means <code>===</code> otherwise.</p>
|
||||
<span class="hljs-keyword">else</span> tag
|
||||
|
||||
tagToken = <span class="hljs-property">@token</span> tag, id, <span class="hljs-number">0</span>, idLength
|
||||
tagToken.origin = [tag, alias, tagToken[<span class="hljs-number">2</span>]] <span class="hljs-keyword">if</span> alias
|
||||
tagToken.variable = <span class="hljs-keyword">not</span> forcedIdentifier
|
||||
<span class="hljs-keyword">if</span> poppedToken
|
||||
[tagToken[<span class="hljs-number">2</span>].first_line, tagToken[<span class="hljs-number">2</span>].first_column] =
|
||||
@@ -484,7 +488,7 @@ interpolation.</p>
|
||||
{tokens, <span class="hljs-attribute">index</span>: end} = <span class="hljs-property">@matchWithInterpolations</span> regex, quote
|
||||
$ = tokens.length - <span class="hljs-number">1</span>
|
||||
|
||||
delimiter = quote[<span class="hljs-number">0</span>]
|
||||
delimiter = quote.charAt(<span class="hljs-number">0</span>)
|
||||
<span class="hljs-keyword">if</span> heredoc</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -817,6 +821,7 @@ parentheses that indicate a method call from regular parentheses, and so on.</p>
|
||||
[..., prev] = <span class="hljs-property">@tokens</span>
|
||||
<span class="hljs-keyword">if</span> value <span class="hljs-keyword">is</span> <span class="hljs-string">'='</span> <span class="hljs-keyword">and</span> prev
|
||||
<span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> prev[<span class="hljs-number">1</span>].reserved <span class="hljs-keyword">and</span> prev[<span class="hljs-number">1</span>] <span class="hljs-keyword">in</span> JS_FORBIDDEN
|
||||
prev = prev.origin <span class="hljs-keyword">if</span> prev.origin
|
||||
<span class="hljs-property">@error</span> <span class="hljs-string">"reserved word '<span class="hljs-subst">#{prev[<span class="hljs-number">1</span>]}</span>' can't be assigned"</span>, prev[<span class="hljs-number">2</span>]
|
||||
<span class="hljs-keyword">if</span> prev[<span class="hljs-number">1</span>] <span class="hljs-keyword">in</span> [<span class="hljs-string">'||'</span>, <span class="hljs-string">'&&'</span>]
|
||||
prev[<span class="hljs-number">0</span>] = <span class="hljs-string">'COMPOUND_ASSIGN'</span>
|
||||
@@ -1766,7 +1771,7 @@ HEREDOC_INDENT = <span class="hljs-regexp">/\n+([^\n\S]*)(?=\S)/g</span></pr
|
||||
| \\[^\n] <span class="hljs-comment"># anything but newlines escaped</span>
|
||||
| \[ <span class="hljs-comment"># character class</span>
|
||||
(?: \\[^\n] | [^ \] \n \\ ] )*
|
||||
]
|
||||
\]
|
||||
)*) (/)?
|
||||
///</span>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -243,11 +243,7 @@ parens. Unwrap all that.</p>
|
||||
<span class="hljs-keyword">new</span> Assign (<span class="hljs-keyword">new</span> Value <span class="hljs-keyword">new</span> Literal <span class="hljs-string">'_'</span>), ast, <span class="hljs-string">'='</span>
|
||||
]
|
||||
js = ast.compile {<span class="hljs-attribute">bare</span>: <span class="hljs-literal">yes</span>, <span class="hljs-attribute">locals</span>: Object.keys(context), referencedVars}
|
||||
result = <span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
|
||||
vm.runInThisContext js, filename
|
||||
<span class="hljs-keyword">else</span>
|
||||
vm.runInContext js, context, filename
|
||||
cb <span class="hljs-literal">null</span>, result
|
||||
cb <span class="hljs-literal">null</span>, runInContext js, context, filename
|
||||
<span class="hljs-keyword">catch</span> err</pre></div></div>
|
||||
|
||||
</li>
|
||||
@@ -266,6 +262,12 @@ parens. Unwrap all that.</p>
|
||||
<div class="content"><div class='highlight'><pre> updateSyntaxError err, input
|
||||
cb err
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">runInContext</span> = <span class="hljs-params">(js, context, filename)</span> -></span>
|
||||
<span class="hljs-keyword">if</span> context <span class="hljs-keyword">is</span> <span class="hljs-built_in">global</span>
|
||||
vm.runInThisContext js, filename
|
||||
<span class="hljs-keyword">else</span>
|
||||
vm.runInContext js, context, filename
|
||||
|
||||
<span class="hljs-function"><span class="hljs-title">addMultilineHandler</span> = <span class="hljs-params">(repl)</span> -></span>
|
||||
{rli, inputStream, outputStream} = repl</pre></div></div>
|
||||
|
||||
@@ -455,7 +457,8 @@ parens. Unwrap all that.</p>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> readFd = fs.openSync filename, <span class="hljs-string">'r'</span>
|
||||
buffer = <span class="hljs-keyword">new</span> Buffer(size)
|
||||
fs.readSync readFd, buffer, <span class="hljs-number">0</span>, size, stat.size - size</pre></div></div>
|
||||
fs.readSync readFd, buffer, <span class="hljs-number">0</span>, size, stat.size - size
|
||||
fs.close readFd</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -525,7 +528,7 @@ parens. Unwrap all that.</p>
|
||||
<div class="content"><div class='highlight'><pre> fs.write fd, <span class="hljs-string">"<span class="hljs-subst">#{code}</span>\n"</span>
|
||||
lastLine = code
|
||||
|
||||
repl.rli.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>,<span class="hljs-function"> -></span> fs.close fd</pre></div></div>
|
||||
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>,<span class="hljs-function"> -></span> fs.close fd</pre></div></div>
|
||||
|
||||
</li>
|
||||
|
||||
@@ -576,7 +579,8 @@ parens. Unwrap all that.</p>
|
||||
process.argv = [<span class="hljs-string">'coffee'</span>].concat process.argv[<span class="hljs-number">2.</span>.]
|
||||
opts = merge replDefaults, opts
|
||||
repl = nodeREPL.start opts
|
||||
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>,<span class="hljs-function"> -></span> repl.outputStream.write <span class="hljs-string">'\n'</span>
|
||||
runInContext opts.prelude, repl.context, <span class="hljs-string">'prelude'</span> <span class="hljs-keyword">if</span> opts.prelude
|
||||
repl.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>,<span class="hljs-function"> -></span> repl.outputStream.write <span class="hljs-string">'\n'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> repl.rli.closed
|
||||
addMultilineHandler repl
|
||||
addHistory repl, opts.historyFile, opts.historyMaxInputSize <span class="hljs-keyword">if</span> opts.historyFile</pre></div></div>
|
||||
|
||||
|
||||
@@ -632,7 +632,7 @@ that creates grammatical ambiguities.</p>
|
||||
</div>
|
||||
|
||||
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">if</span> tag <span class="hljs-keyword">in</span> IMPLICIT_FUNC <span class="hljs-keyword">and</span>
|
||||
<span class="hljs-property">@indexOfTag</span>(i + <span class="hljs-number">1</span>, <span class="hljs-string">'INDENT'</span>, <span class="hljs-literal">null</span>, <span class="hljs-string">':'</span>) > -<span class="hljs-number">1</span> <span class="hljs-keyword">and</span>
|
||||
<span class="hljs-property">@indexOfTag</span>(i + <span class="hljs-number">1</span>, <span class="hljs-string">'INDENT'</span>) > -<span class="hljs-number">1</span> <span class="hljs-keyword">and</span> <span class="hljs-property">@looksObjectish</span>(i + <span class="hljs-number">2</span>) <span class="hljs-keyword">and</span>
|
||||
<span class="hljs-keyword">not</span> <span class="hljs-property">@findTagsBackwards</span>(i, [<span class="hljs-string">'CLASS'</span>, <span class="hljs-string">'EXTENDS'</span>, <span class="hljs-string">'IF'</span>, <span class="hljs-string">'CATCH'</span>,
|
||||
<span class="hljs-string">'SWITCH'</span>, <span class="hljs-string">'LEADING_WHEN'</span>, <span class="hljs-string">'FOR'</span>, <span class="hljs-string">'WHILE'</span>, <span class="hljs-string">'UNTIL'</span>])
|
||||
startImplicitCall i + <span class="hljs-number">1</span>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var volume, winner;
|
||||
|
||||
if (ignition === true) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var courses, dish, food, foods, i, j, k, l, len, len1, len2, ref;
|
||||
|
||||
ref = ['toast', 'cheese', 'wine'];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
|
||||
/*
|
||||
SkinnyMochaHalfCaffScript Compiler v1.0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var fs;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
$('body').click(function(e) {
|
||||
return $('.box').fadeIn('fast').addClass('.active');
|
||||
}).css('background', 'white');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var Animal, Horse, Snake, sam, tom,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var cholesterol, healthy;
|
||||
|
||||
cholesterol = 127;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var date, mood;
|
||||
|
||||
if (singing) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var Person, tim;
|
||||
|
||||
Person = (function() {
|
||||
function Person(options) {
|
||||
this.name = options.name, this.age = options.age, this.height = options.height;
|
||||
var ref;
|
||||
this.name = options.name, this.age = options.age, this.height = (ref = options.height) != null ? ref : 'average';
|
||||
}
|
||||
|
||||
return Person;
|
||||
@@ -11,5 +12,6 @@ Person = (function() {
|
||||
})();
|
||||
|
||||
tim = new Person({
|
||||
name: 'Tim',
|
||||
age: 4
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var fill;
|
||||
|
||||
fill = function(container, liquid) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var filename, fn, i, len;
|
||||
|
||||
fn = function(filename) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var hi;
|
||||
|
||||
hi = function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var footprints, solipsism, speed;
|
||||
|
||||
if ((typeof mind !== "undefined" && mind !== null) && (typeof world === "undefined" || world === null)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.10.0
|
||||
var first, last, ref, text;
|
||||
|
||||
text = "Every literary critic believes he will outwit history and have the last word";
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user