module.exports = { Inc: Inc, Load: Load }; var utils = require('./utils.js'); var logger = require('./logger.js'); const statFile = "stats/stats"; const writeInterval = 10; var data = {}; var writes = 0; function Load() { try { var prevData = utils.ReadFile(statFile); data = JSON.parse(prevData); } catch (e) { logger.Log("[STAT]: Error at loading logs!", logger.GetColor("redbg")); console.log(e); } } function Inc(value) { if (value.startsWith("/?")) value = "/"; if (data[value] == undefined) data[value] = 0; data[value]++; Save(); } function Save() { writes++; if (writes == writeInterval) { try { utils.WriteFile(JSON.stringify(data), statFile); writes = 0; // logger.Log("[STAT] Stats wrote."); } catch (e) { logger.Log("[STAT]: Error at writing logs!", logger.GetColor("redbg")); console.log(e); } } }