Skip to content

Instantly share code, notes, and snippets.

@copyrighthero
Created October 9, 2018 07:41
Show Gist options
  • Save copyrighthero/bc248ed25610c7f9ffd849d1e8dac3ea to your computer and use it in GitHub Desktop.
Save copyrighthero/bc248ed25610c7f9ffd849d1e8dac3ea to your computer and use it in GitHub Desktop.
UMD JavaScript
void function (global, factory) {
'use strict';
// module identifier
var identifier = 'identifier';
// module exportation
if (typeof define === 'function' && define.amd) {
// AMD module
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-Like module
module.exports = factory();
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
// CommonJS strict module
exports[identifier] = factory();
} else {
// Global module
global[identifier] = factory();
}
} (this, function () { return function () {
'use strict';
}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment