-
-
Save hfcorriez/d01c9742021e4f86005a08629acdd381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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