fix: avoid to modify stored charging profiles
[e-mobility-charging-stations-simulator.git] / src / performance / storage / JsonFileStorage.ts
index 648b9c62f292474b0b6dcd3d871af4c0849fa36d..97ab104ccfb73a11fb52aafd8ca408eeaf1ff84f 100644 (file)
@@ -4,13 +4,8 @@ import { closeSync, existsSync, mkdirSync, openSync, writeSync } from 'node:fs'
 import { dirname } from 'node:path'
 
 import { BaseError } from '../../exception/index.js'
-import { FileType, type Statistics } from '../../types/index.js'
-import {
-  AsyncLock,
-  AsyncLockType,
-  handleFileException,
-  JSONStringifyWithMapSupport
-} from '../../utils/index.js'
+import { FileType, MapStringifyFormat, type Statistics } from '../../types/index.js'
+import { AsyncLock, AsyncLockType, handleFileException, JSONStringify } from '../../utils/index.js'
 import { Storage } from './Storage.js'
 
 export class JsonFileStorage extends Storage {
@@ -28,11 +23,11 @@ export class JsonFileStorage extends Storage {
       writeSync(
         // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
         this.fd!,
-        JSONStringifyWithMapSupport([...this.getPerformanceStatistics()], 2),
+        JSONStringify([...this.getPerformanceStatistics()], 2, MapStringifyFormat.object),
         0,
         'utf8'
       )
-    }).catch(error => {
+    }).catch((error: unknown) => {
       handleFileException(
         this.dbName,
         FileType.PerformanceRecords,