Skip to content

Instantly share code, notes, and snippets.

@ali-master
Created October 1, 2016 10:19
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 ali-master/f1aebcb7987d383b7111126121d658a6 to your computer and use it in GitHub Desktop.
Save ali-master/f1aebcb7987d383b7111126121d658a6 to your computer and use it in GitHub Desktop.
Export Function in AMD And CommonJS
(function(global, factory) {
/*global define: false*/
/*global exports: true*/
if (typeof exports === 'object' && exports) {
factory(exports); // CommonJS
} else if (typeof define === 'function' && define.amd) {
define(['exports'], factory); // AMD
} else {
factory(global); // <script>
}
} (this, function(global) {
// your code..
global === window // return true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment