Created
September 17, 2012 08:34
-
-
Save benperiton/3736194 to your computer and use it in GitHub Desktop.
ElReg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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