Uma rápida olhada em minha maneira de criar módulos:
/**
* A simple example how I structure my modules in javascript
*
*/
var Module = (function () {
/**
* This is the `constructor` of our `Module`
*
*/
var Module = function (options) {
// define some default options
this.options = {
key: 'value'
};
// merge the `options` with our defaults
for (var key in options) {
this.options[key] = options[key];
}
};
/**
* This is a `method` of or `Module`
*
*/
Module.prototype.method = function () {
};
return Module;
}());