Skip to content

Instantly share code, notes, and snippets.

@arturparkhisenko
Last active December 11, 2015 22:03
Show Gist options
  • Save arturparkhisenko/d176b383b0d2dc3304ba to your computer and use it in GitHub Desktop.
Save arturparkhisenko/d176b383b0d2dc3304ba to your computer and use it in GitHub Desktop.
js-module-es5 (Node.js|CommonJS / AMD / Default to window as global)
(function(exports) {
'use strict';
function foo() {}
// Node.js|CommonJS / AMD / Default to window as global
if (typeof module !== 'undefined' && module.exports) {
module.exports = exports = foo;
} else if (typeof define === 'function' && define.amd) {
define(function() {
return foo;
});
} else if (typeof window === 'object') {
window.foo = foo;
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment