Exporting a new object in Node.js -


how can pass variables port,host,database function?

//myjs.js

var rediscaller = function(port,host,database){  };  module.exports = new rediscaller(); 

if do:

var myjs = require('./myjs'); 

how pass variables?

seems way this:

module.exports = function(port,host,database){      return new rediscaller(port,host,database); } 

change myjs.js to:

module.exports = rediscaller;

then can do:

var myjs = require('./myjs')(port,host,database);


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -