Last active
December 16, 2015 03:49
-
-
Save ricogallo/5372755 to your computer and use it in GitHub Desktop.
Universally loadable module
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
// Universally loadable script, drawn from https://github.com/kriskowal/q | |
(function (definition) { | |
// Montage Require | |
if (typeof bootstrap === "function") { | |
bootstrap("promise", definition); | |
// CommonJS | |
} else if (typeof exports === "object") { | |
module.exports = definition(); | |
// RequireJS | |
} else if (typeof define === "function" && define.amd) { | |
define(definition); | |
// SES (Secure EcmaScript) | |
} else if (typeof ses !== "undefined") { | |
if (!ses.ok()) { | |
return; | |
} else { | |
ses.makeFoo = definition; | |
} | |
// <script> | |
} else { | |
Foo = definition(); | |
} | |
})(function () { | |
"use strict"; | |
return {foo: "bar"} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment