Created
October 20, 2013 07:17
-
-
Save anasnakawa/7065952 to your computer and use it in GitHub Desktop.
AMD / CommonJs (NodeJs) / Browser wrapper pattern
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
// AMD / Common Js / Browser Wrapper pattern | |
// copyright to [millermedeiros](https://github.com/millermedeiros/js-signals/blob/master/src/wrapper.js) | |
// --------------------------------- | |
(function(global){ | |
var libName; | |
// define your library | |
//exports to multiple environments | |
if(typeof define === 'function' && define.amd){ //AMD | |
define(function () { return libName; }); | |
} else if (typeof module !== 'undefined' && module.exports){ //node | |
module.exports = libName; | |
} else { //browser | |
//use string because of Google closure compiler ADVANCED_MODE | |
global['libName'] = libName; | |
} | |
}(this)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment