-
-
Save Raynos/915930 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//main.js | |
var util = require('util'); | |
util.debug('main initializing'); | |
var someMod = require('./someModule').makeApp('SomeApp', 'Tom'); | |
someMod.displayAppName(); | |
someMod.displayUserName(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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