when all you need is a json file hot loaded into memory when the file changes.
- You know if you move it to a file, you'll have to read from the disk every time, and you know that's bad.
- You know that if you create a watcher, that is better because it will only have to watch for changes and parse and read only when needed
- You are too lazy to make a wrapper class for fs.watch + fs.read and/or busy doing other things
Install the module with:
npm install autoupdatedjson
var auj = ;// register ./test/configfile.json to the configfile keyauj;// get the data for 'configfile'auj;// call get(key, fn) as often as you like, the watcher will keep 'configfile' updated// will only dip to file i/o and parse when it needs to instead of parsing every time// when you are doneconfigfilewatcher;