Skip to content

Instantly share code, notes, and snippets.

@Raynos
Forked from tommedema/main.js
Created April 12, 2011 17:05
Show Gist options
  • Save Raynos/915930 to your computer and use it in GitHub Desktop.
Save Raynos/915930 to your computer and use it in GitHub Desktop.
//main.js
var util = require('util');
util.debug('main initializing');
var someMod = require('./someModule').makeApp('SomeApp', 'Tom');
someMod.displayAppName();
someMod.displayUserName();
//someModule.js
(function() {
var makeApp = function(appName, userName) {
return new App(appName, userName);
}
var App = function(appName, userName) {
var util = require('util');
this.displayAppName = function() {
util.debug('app name: ' + appName);
}
this.displayUserName = function() {
util.debug('user name: ' + userName);
}
// this is returned by default :(
// also your writing to this without calling new
//return this;
}
module.exports.makeApp = makeApp;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment