Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@J2TEAM
Last active January 9, 2016 09:54
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 J2TEAM/6c4822a42316c79daf51 to your computer and use it in GitHub Desktop.
Save J2TEAM/6c4822a42316c79daf51 to your computer and use it in GitHub Desktop.
// Ref: https://github.com/umdjs/umd/blob/master/templates/amdWeb.js
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['moduleName'], factory);
} else {
root.moduleName = factory(root.moduleName);
}
}(this, function(moduleName) {
'use strict';
var privateVar, privateMethod;
privateVar = 'something';
privateMethod = function(name) {
console.log('Hello, ' + name);
};
// Public variables and methods
return {
publicVar: 'something else',
publicMethod: function() {
return privateVar; // Access to private variable
}
};
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment