Skip to content

Instantly share code, notes, and snippets.

@tolu
Created August 17, 2014 13:58
Show Gist options
  • Save tolu/3b9bb490a8e67b3938dd to your computer and use it in GitHub Desktop.
Save tolu/3b9bb490a8e67b3938dd to your computer and use it in GitHub Desktop.
JS module
(function (definition) {
// Turn off strict mode for this function so we can assign to global
/* jshint strict: false */
// This file will function properly as a <script> tag, or a module
// using CommonJS and NodeJS or RequireJS module formats. In
// Common/Node/RequireJS, the module exports the API and when
// executed as a simple <script>, it creates a global instead.
// 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 {
myModule = definition();
}
})(function () {
"use strict";
var module = {};
return module;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment