Skip to content

Instantly share code, notes, and snippets.

@iTonyYo
Forked from wilsonpage/umd-module.js
Created January 24, 2014 15:00
Show Gist options
  • Save iTonyYo/8598879 to your computer and use it in GitHub Desktop.
Save iTonyYo/8598879 to your computer and use it in GitHub Desktop.
umd(function(require, exports, module) {
//...
},'my-module');function umd(fn,n){
if(typeof define=='function')return define(fn); // AMD
if(typeof module=='object')return fn(require,exports,module); // CommonJS
var m={exports:{}};window[n]=fn(function(n){return window[n];},m.exports,m)||m.exports; // window
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment