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
Post a Comment