- const fileData = readFileSync(this.dbName, 'utf8');
- const performanceRecords: Statistics[] = fileData
- ? (JSON.parse(fileData) as Statistics[])
- : [];
- performanceRecords.push(performanceStatistics);
- writeFileSync(this.dbName, JSONStringifyWithMapSupport(performanceRecords, 2), 'utf8');
+ JsonFileStorage.performanceRecords.set(performanceStatistics.id, performanceStatistics);
+ writeSync(
+ this.fd!,
+ JSONStringifyWithMapSupport([...JsonFileStorage.performanceRecords.values()], 2),
+ 0,
+ 'utf8',
+ );