This is a high-level configuration system for your application. You just need to create a default configuration file defaults.json and put it near initial script. Then all you need to do is to create instance of Pragma Config constructor and it will already have all default values inside. If you want to apply current configuration just pass path to configuration file or config object itself in constructor. Specified configuration and default configuration will be automatically merged including all nested levels.
Pragma Config has a few useful features:
To install just use NPM
npm install pragma-config
Put defaults.json near your initial script
Then use the force of node.js
var PragmaConfig =// you can specify a config object or path to json file in constructorconfig =superParameter: 'superValue!'cat:eyes: 'happy'mind: 'calm';// here is config file change event// (to try this, please start main.js and edit defaults.json file)config;// another exception-free value getterconsole; // superValueconsole; // 4console; // whiteconsole; // calm// here example for whole directory 'currents' with files 'section1.json' and 'section2.json'var directoryTest = './currents';// if 'section1.json' is changed this event will tell you aboutdirectoryTest;// lets output some value from 'section2.json'console;// and of course you can specify directory as default values toovar directoryTest2 = './currents' './defaults';// it will merge sections accordingly with file names in these directories
Pragma Dudes wish you live long and prosper.