Skip to content

Instantly share code, notes, and snippets.

@sjwilliams
Forked from wilsonpage/umd-module.js
Created January 24, 2014 15:49
Show Gist options
  • Save sjwilliams/8599924 to your computer and use it in GitHub Desktop.
Save sjwilliams/8599924 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