I'm trying to create a require which is unique for each require use, file 1, 2, 300 etc all have a require say of a file called test.js. this can then be disabled in one file but it's variables be untouched in the other files.
File1.js
const test = require("./test.js"); // NOTE enabled boolean in test is default = true test.enabled = false; // or test.disable(); test.sayHello(); // will output nothing as enabled = false
File2.js
const test = require("./test.js"); test.sayHello(); // Should output hello but it as file1 set enabled to false it dosnt
What would test.js look like to achieve this functionality?
I am currently having to do this via an argument in the module.exports function, which is not ideal. eg disable would be test direct return of the function and then a 2nd optional argument for enable/disable. Which is meh...
Thanks
D