Skip to content

Instantly share code, notes, and snippets.

@hfcorriez
Forked from jaridmargolin/intro.js
Created July 14, 2017 11:18
Show Gist options
  • Save hfcorriez/d01c9742021e4f86005a08629acdd381 to your computer and use it in GitHub Desktop.
Save hfcorriez/d01c9742021e4f86005a08629acdd381 to your computer and use it in GitHub Desktop.
;(function (id, name, context, definition) {
// --------------------------------------------------------------------------
// Dependencies
//
// This is an attempt to make this library compatible with multiple module
// formats. Other UMD implementations do not take into account dependencies:
// Example: https://github.com/ForbesLindesay/umd/blob/master/template.js
//
// **NOTE: Named AMD modules are more suitable for libraries as it provides
// a consistent naming convention to access it by (anonymous AMD modules are
// better suited on an app level where files/paths may be changed).
// --------------------------------------------------------------------------
var deps = [];
// CommonJS
if (typeof module !== 'undefined' && module.exports) {
for (var i = 0, l = deps.length; i < l; i++) {
deps[i] = require(deps[i])
};
module.exports = definition.apply(context, deps);
// AMD
} else if (typeof define === 'function' && define.amd) {
define(id, deps, definition);
// STANDARD
} else {
context[name] = definition.apply(context, deps);
}
})('amdName', 'contextName', this, function () {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment