I have a module to set config. It's working. I want to get config using same module. I don't want to use additional file.
I tried a code something like that:
let config_defaults = { test_option: false };
let active_config;
if(active_config === undefined){ active_config = config_defaults };
exports.getcfg = active_config;
const setcfg function(options){
options = Object.assign({}, config_defaults, options);
active_config = options;
return(options);
}; exports.setcfg = select_config;
setcfg
returns changes with no problem. But I can't get changes at getcfg
. Is it possible to get changes without using additional file?
Outputs:
console.log( testmodule.setcfg({test_option: true}) ); /* >> Output: { test_option: true } */
console.log( testmodule.getcfg ); /* >> Output: { test_option: false } */