Created
November 9, 2011 03:04
-
-
Save unscriptable/1350202 to your computer and use it in GitHub Desktop.
boilerplate for CommonJS, AMD, plain old global hackfest
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
(function (myLib, define) { | |
//Set up myLib here. | |
myLib.add = function (a, b) { return a + b; }; | |
define(myLib); | |
}.call(this, | |
typeof exports == 'object' ? exports : {}, | |
typeof define == 'function' && define.amd ? | |
define : | |
function (lib) { typeof exports == 'object' || this.myLib = lib; } | |
); |
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
(function (myLib, define) { | |
//Set up myLib here. | |
myLib.add = function (a, b) { return a + b; }; | |
define(myLib); | |
}.call(this, | |
typeof exports == 'object' ? exports : {}, | |
typeof define == 'function' && define.amd ? | |
define : | |
function (lib) { typeof exports == 'object' || (this.myLib = lib); } | |
)); |
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
(function (myLib, define) { | |
//Set up myLib here. | |
myLib.add = function (a, b) { return a + b; }; | |
define(myLib); | |
}.apply(this, typeof exports == 'object' ? | |
[exports, function () {}] : | |
[{}, typeof define == 'function' && define.amd ? define : function (lib) { this.myLib = lib; }] | |
)); |
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
// no global hackfest | |
(function (myLib, define) { | |
//Set up myLib here. | |
myLib.add = function (a, b) { return a + b; }; | |
define(myLib); | |
}.call(this, | |
typeof exports == 'object' ? exports : {}, | |
typeof define == 'function' && define.amd ? define : function () {} | |
)); |
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
// no global hackfest | |
var define = typeof define == 'undefined' ? function (def) { def(require, exports, module); } : define; | |
define(function (require, exports, module) { | |
//Set up myLib here. | |
exports.add = function (a, b) { return a + b; }; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment