Skip to content

Instantly share code, notes, and snippets.

@benperiton
Created September 17, 2012 08:34
Show Gist options
  • Save benperiton/3736194 to your computer and use it in GitHub Desktop.
Save benperiton/3736194 to your computer and use it in GitHub Desktop.
ElReg
Consider this mockup in JS:
(function (global) {
function myThing ($opts) {
this.opts = $opts || {};
}
myThing.prototype.test = function () {
return this.opts;
};
global.myThing = myThing;
}(this));
In CS:
((global) ->
myThing = ($opts) ->
@opts = $opts or {}
myThing::test = ->
@opts
global.myThing = myThing
) this
And CS converted back to JS:
(function(global) {
var myThing;
myThing = function($opts) {
return this.opts = $opts || {};
};
myThing.prototype.test = function() {
return this.opts;
};
return global.myThing = myThing;
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment