Skip to content

Instantly share code, notes, and snippets.

@dan-cooke
Last active May 23, 2017 10:27
Show Gist options
  • Save dan-cooke/2878c5bd77fdeef794d37973623fdaf0 to your computer and use it in GitHub Desktop.
Save dan-cooke/2878c5bd77fdeef794d37973623fdaf0 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/dabebax
//module test
'use strict';
//the namespace that will be exported
var myModule = {};
//wrapper function to export all as one namespace
(function wrapper(exports) {
(function existsModule(exports) {
var api = {
moduleExists: function moduleExists() {
return true;
}
};
Object.assign(exports, api);
})(typeof exports === 'undefined' ? window : exports);
})(myModule);
console.log(myModule.moduleExists);
@dan-cooke
Copy link
Author

Module Pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment