()
| 6 | |
| 7 | // Function to read data from JSON file |
| 8 | function readDataFromFile() { |
| 9 | try { |
| 10 | const data = fs.readFileSync(dataFilePath, 'utf-8'); |
| 11 | return JSON.parse(data); |
| 12 | } catch (error) { |
| 13 | // If file doesn't exist or there's a read error, return an empty object |
| 14 | console.error('Error reading data from file:', error); |
| 15 | return {}; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | // Function to write data to JSON file |
| 20 | function writeDataToFile(data) { |
no outgoing calls
no test coverage detected