Skip to content

Commit

Permalink
going back to the Closure Compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Oct 20, 2010
1 parent 54d9b28 commit 35b6a70
Show file tree
Hide file tree
Showing 9 changed files with 480 additions and 59 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -2,7 +2,7 @@ require 'erb'
require 'fileutils' require 'fileutils'
require 'rake/testtask' require 'rake/testtask'
require 'rubygems' require 'rubygems'
require 'yui/compressor' require 'closure-compiler'


HEADER = <<-EOS HEADER = <<-EOS
/** /**
Expand Down Expand Up @@ -42,7 +42,7 @@ task :browser do
} }
JS JS
end end
code = YUI::JavaScriptCompressor.new.compress(<<-"JS") code = Closure::Compiler.new.compress(<<-"JS")
this.CoffeeScript = function(){ this.CoffeeScript = function(){
function require(path){ return require[path] } function require(path){ return require[path] }
#{ code } #{ code }
Expand Down
2 changes: 1 addition & 1 deletion documentation/js/aliases.js
Expand Up @@ -11,7 +11,7 @@ if (answer !== false) {
if (car.speed < limit) { if (car.speed < limit) {
accelerate(); accelerate();
} }
if ((47 === pick || 92 === pick || 13 === pick)) { if ((pick === 47 || pick === 92 || pick === 13)) {
winner = true; winner = true;
} }
print(inspect("My name is " + this.name)); print(inspect("My name is " + this.name));
14 changes: 7 additions & 7 deletions documentation/js/array_comprehensions.js
@@ -1,16 +1,16 @@
var _i, _len, _len2, _ref, _result, food, lunch, pos, roid, roid2; var _i, _len, _len2, _ref, _ref2, _result, food, lunch, pos, roid, roid2;
lunch = (function() { lunch = (function() {
_result = []; _ref = ['toast', 'cheese', 'wine']; _result = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = (_ref = ['toast', 'cheese', 'wine']).length; _i < _len; _i++) {
food = _ref[_i]; food = _ref[_i];
_result.push(eat(food)); _result.push(eat(food));
} }
return _result; return _result;
})(); })();
for (pos = 0, _len = asteroids.length; pos < _len; pos++) { for (pos = 0, _len = (_ref = asteroids).length; pos < _len; pos++) {
roid = asteroids[pos]; roid = _ref[pos];
for (_i = 0, _len2 = asteroids.length; _i < _len2; _i++) { for (_i = 0, _len2 = (_ref2 = asteroids).length; _i < _len2; _i++) {
roid2 = asteroids[_i]; roid2 = _ref2[_i];
if (roid !== roid2) { if (roid !== roid2) {
if (roid.overlaps(roid2)) { if (roid.overlaps(roid2)) {
roid.explode(); roid.explode();
Expand Down
14 changes: 8 additions & 6 deletions documentation/js/classes.js
@@ -1,35 +1,37 @@
var Animal, Horse, Snake, sam, tom; var Animal, Horse, Snake, sam, tom;
var __extends = function(child, parent) { var __extends = function(child, parent) {
var ctor = function() {}; function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype; ctor.prototype = parent.prototype;
child.prototype = new ctor(); child.prototype = new ctor;
child.prototype.constructor = child;
if (typeof parent.extended === "function") parent.extended(child); if (typeof parent.extended === "function") parent.extended(child);
child.__super__ = parent.prototype; child.__super__ = parent.prototype;
}; };
Animal = (function() { Animal = (function() {
return function Animal(_arg) { function Animal(_arg) {
this.name = _arg; this.name = _arg;
return this; return this;
}; };
return Animal;
})(); })();
Animal.prototype.move = function(meters) { Animal.prototype.move = function(meters) {
return alert(this.name + " moved " + meters + "m."); return alert(this.name + " moved " + meters + "m.");
}; };
Snake = (function() { Snake = (function() {
return function Snake() { function Snake() {
return Animal.apply(this, arguments); return Animal.apply(this, arguments);
}; };
return Snake;
})(); })();
__extends(Snake, Animal); __extends(Snake, Animal);
Snake.prototype.move = function() { Snake.prototype.move = function() {
alert("Slithering..."); alert("Slithering...");
return Snake.__super__.move.call(this, 5); return Snake.__super__.move.call(this, 5);
}; };
Horse = (function() { Horse = (function() {
return function Horse() { function Horse() {
return Animal.apply(this, arguments); return Animal.apply(this, arguments);
}; };
return Horse;
})(); })();
__extends(Horse, Animal); __extends(Horse, Animal);
Horse.prototype.move = function() { Horse.prototype.move = function() {
Expand Down
6 changes: 3 additions & 3 deletions documentation/js/expressions_comprehension.js
@@ -1,9 +1,9 @@
var _result, globals, name; var _ref, _result, globals, name;
var __hasProp = Object.prototype.hasOwnProperty; var __hasProp = Object.prototype.hasOwnProperty;
globals = (function() { globals = (function() {
_result = []; _result = [];
for (name in window) { for (name in _ref = window) {
if (!__hasProp.call(window, name)) continue; if (!__hasProp.call(_ref, name)) continue;
_result.push(name); _result.push(name);
} }
return _result; return _result;
Expand Down
6 changes: 4 additions & 2 deletions documentation/js/range_comprehensions.js
Expand Up @@ -4,16 +4,18 @@ countdown = (function() {
for (num = 10; num >= 1; num--) { for (num = 10; num >= 1; num--) {
_result.push(num); _result.push(num);
} }
num--;
return _result; return _result;
})(); })();
deliverEggs = function() { deliverEggs = function() {
var _ref, _result2, dozen, i; var _ref, _result2, dozen, i;
_result2 = []; _ref = eggs.length; _result2 = [];
for (i = 0; (0 <= _ref ? i < _ref : i > _ref); i += 12) { for (i = 0, _ref = eggs.length; (0 <= _ref ? i < _ref : i > _ref); i += 12) {
_result2.push((function() { _result2.push((function() {
dozen = eggs.slice(i, i + 12); dozen = eggs.slice(i, i + 12);
return deliver(new eggCarton(dozen)); return deliver(new eggCarton(dozen));
})()); })());
} }
i -= 12;
return _result2; return _result2;
}; };
4 changes: 2 additions & 2 deletions documentation/js/soaks.js
@@ -1,2 +1,2 @@
var _ref, _ref2; var _ref;
(((_ref = lottery.drawWinner()) != null) ? (((_ref2 = _ref.address) != null) ? _ref2.zipcode : undefined) : undefined); (typeof lottery.drawWinner === "function" ? (((_ref = lottery.drawWinner().address) != null) ? _ref.zipcode : undefined) : undefined);
406 changes: 405 additions & 1 deletion extras/coffee-script.js

Large diffs are not rendered by default.

83 changes: 48 additions & 35 deletions index.html

Large diffs are not rendered by default.

0 comments on commit 35b6a70

Please sign in to comment.