Skip to content

Instantly share code, notes, and snippets.

@creynders
Last active December 17, 2015 20:38
Show Gist options
  • Save creynders/5668852 to your computer and use it in GitHub Desktop.
Save creynders/5668852 to your computer and use it in GitHub Desktop.
JS snippets
(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