Skip to content

Instantly share code, notes, and snippets.

@TrevorJTClarke
Created March 31, 2015 23:10
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 TrevorJTClarke/7f904ee0289570bae80d to your computer and use it in GitHub Desktop.
Save TrevorJTClarke/7f904ee0289570bae80d to your computer and use it in GitHub Desktop.
A standard for building javascript modules -- pre-ES6
/**
* Module Starter
*/
var NS = "ModuleName";
// load the module into global
window[NS] = (function(){
/**
* Internal - encapsulates all logic
*
* Arguments
* options: provides entry method for any needed arguments
*/
function Internal (options) {
options = options || {};
// extra starting functions
}
// extend the Internal methods
Internal.prototype = {
get: function () {
console.log("get method");
}
};
// assign the Internal function to external methods
return new Internal();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment