Last active
December 17, 2015 20:38
-
-
Save creynders/5668852 to your computer and use it in GitHub Desktop.
JS snippets
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) { | |
/* | |
AMD/CommonJS compatibility largely stolen from https://github.com/kriskowal/q/blob/master/q.js | |
*/ | |
// Turn off strict mode for this function so we can assign to global | |
/*jshint strict: false, -W117*/ | |
// 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. | |
// CommonJS | |
if (typeof exports === "object") { | |
module.exports = definition(); | |
// RequireJS | |
} else if (typeof define === "function" && define.amd) { | |
define(definition); | |
// <script> | |
} else { | |
/*HERE BE NAMESPACE*/ = definition(); | |
} | |
})(function () { | |
"use strict"; | |
/*HERE BE CODE*/ | |
return { | |
/*HERE BE API*/ | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment