Created
August 31, 2013 05:35
-
-
Save bpander/6396399 to your computer and use it in GitHub Desktop.
How to define a js 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
(function (definition) { | |
// Turn off strict mode for this function so we can assign to global | |
/* jshint strict: false */ | |
// 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.makeQ = definition; | |
} | |
// <script> | |
} else { | |
Module = definition(); | |
} | |
})(function () { | |
"use strict"; | |
// THE ACTUAL MODULE DEFINITION | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment