X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fperformance%2Fstorage%2FJsonFileStorage.ts;h=c4a9f7483e30060047607bdbad5a97e15fb7c91c;hb=3e8d029bbd0a072ae80c45e9a50770de3218cbc1;hp=e1a9a44ed796e66e5639c45660850cb7b54fdbf9;hpb=d972af76b6d7d1d2a099d254eacf45245b5316ac;p=e-mobility-charging-stations-simulator.git diff --git a/src/performance/storage/JsonFileStorage.ts b/src/performance/storage/JsonFileStorage.ts index e1a9a44e..c4a9f748 100644 --- a/src/performance/storage/JsonFileStorage.ts +++ b/src/performance/storage/JsonFileStorage.ts @@ -6,7 +6,14 @@ import { dirname } from 'node:path'; import { Storage } from './Storage'; import { BaseError } from '../../exception'; import { FileType, type Statistics } from '../../types'; -import { AsyncLock, AsyncLockType, Constants, Utils, handleFileException } from '../../utils'; +import { + AsyncLock, + AsyncLockType, + Constants, + JSONStringifyWithMapSupport, + handleFileException, + isNullOrUndefined, +} from '../../utils'; export class JsonFileStorage extends Storage { private fd: number | null = null; @@ -25,11 +32,7 @@ export class JsonFileStorage extends Storage { ? (JSON.parse(fileData) as Statistics[]) : []; performanceRecords.push(performanceStatistics); - writeFileSync( - this.dbName, - Utils.JSONStringifyWithMapSupport(performanceRecords, 2), - 'utf8' - ); + writeFileSync(this.dbName, JSONStringifyWithMapSupport(performanceRecords, 2), 'utf8'); }) .catch((error) => { handleFileException( @@ -46,7 +49,7 @@ export class JsonFileStorage extends Storage { public open(): void { try { - if (Utils.isNullOrUndefined(this?.fd)) { + if (isNullOrUndefined(this?.fd)) { if (!existsSync(dirname(this.dbName))) { mkdirSync(dirname(this.dbName), { recursive: true }); }