Thursday, 4 May 2017

Node define unique filename that I need to use across the modules

Currently I am just passing my fileName like that:

let shortid = require('shortid');
let fileName = shortid.generate();

module1.run(fileName);
module2.run(fileName);
module3.run(fileName);

Which I think in not quite right, I might need to pass more things to my modules later on, so I want to avoid to pass that as function params.

What is the best way to approach that in nodejs?

Will global object like global.filename = shortid.generate(); I just read that global is not good... So will do in that case or would you approach that different?



via sreginogemoh

No comments:

Post a Comment