Skip to content

Instantly share code, notes, and snippets.

@bishopZ
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bishopZ/f44dca19d22b9de96958 to your computer and use it in GitHub Desktop.
Save bishopZ/f44dca19d22b9de96958 to your computer and use it in GitHub Desktop.
Require.js & CommonJS & Node compatible module creation
function(name, root, factory){
if (typeof define !== 'undefined' && define.amd) {
define(name, ['dependency'], factory);
} else if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = factory;
}
exports[name] = factory;
} else {
root[name] = factory;
}
})('myModule', window||this||{}, function(){
var myModule = function(){};
// ... write your module code here ... \\
return myModule;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment