Skip to content

Instantly share code, notes, and snippets.

@jamesflorentino
Created September 25, 2012 11:18
Show Gist options
  • Save jamesflorentino/3781201 to your computer and use it in GitHub Desktop.
Save jamesflorentino/3781201 to your computer and use it in GitHub Desktop.
Template for defining a JavaScript module.
(function() {
var TestModule = (function() {
function Module() {
/** constructor **/
}
/** prototype methods **/
Module.prototype = {
create : function() {},
read : function() {},
update : function() {},
delete : function() {}
}
return Module;
})();
// For AMD libraries like RequireJS.
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
define(function() {
return TestModule;
});
}
// For Node.js and Ringo.js
if (typeof module == 'object' && module) {
module.exports = TestModule;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment