Skip to content

Instantly share code, notes, and snippets.

@OctavioBR
Created March 19, 2020 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OctavioBR/b9c4a6fce4ac7934da94792437e78e7e to your computer and use it in GitHub Desktop.
Save OctavioBR/b9c4a6fce4ac7934da94792437e78e7e to your computer and use it in GitHub Desktop.
That vanilla js snippet which avoids polluting global scope exporting a single namespace
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.YourNameSpace = factory());
}(this, function () {
'use strict';
function method() {}
var YourNameSpace = {
method: method
};
return YourNameSpace;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment