INSTALLATION: npm install dynamo-counter
Usage: On calling the function counter('filename'), First of all it will create a folder named counter in home directory of the project. Inside that folder will create a json file with the name that you have passed while calling the function. On keeping the service active if you delete the file/ folder will show an error that corresponding thing is missing.
Example:
var count = require('dynamo-counter'); count.counter('checking'); //Will create a folder named counter, inside that checking.json file with content {"count":0}
//this will all done synchronously.
var path = require('path'); var appDir = path.dirname(require.main.filename); var counterDir = appDir +'/counter/checking.json'; var obj = JSON.parse(fs.readFileSync(counterDir)); count = obj.count; console.log(count);
while calling this function again and again it will increment by 1.