Skip to content

Instantly share code, notes, and snippets.

@anasnakawa
Created October 20, 2013 07:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anasnakawa/7065952 to your computer and use it in GitHub Desktop.
Save anasnakawa/7065952 to your computer and use it in GitHub Desktop.
AMD / CommonJs (NodeJs) / Browser wrapper pattern
// 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