Minor code cleanup
This commit is contained in:
@@ -10,7 +10,6 @@ export class CalculatorUnavailableError extends Error {
|
||||
|
||||
export class CalculatorService {
|
||||
private calculator: LevelCalculator | null = null;
|
||||
private appliedConfigStringified: string | null = null;
|
||||
Standards: StandardsService = new StandardsService();
|
||||
|
||||
constructor() {
|
||||
@@ -26,18 +25,16 @@ export class CalculatorService {
|
||||
|
||||
private async refresh(): Promise<void> {
|
||||
const standardsConfig = await this.Standards.Config.get();
|
||||
const standardsConfigStringified = JSON.stringify(standardsConfig);
|
||||
|
||||
if (this.calculator) {
|
||||
// avoid instatiating a new Standards object if nothing changed
|
||||
if (standardsConfigStringified === this.appliedConfigStringified) return;
|
||||
// avoid instantiating a new Standards object if nothing changed
|
||||
if (JSON.stringify(standardsConfig) === JSON.stringify(this.calculator.standards.cfg)) return;
|
||||
|
||||
this.calculator.Standards = new Standards(standardsConfig);
|
||||
this.calculator.standards = new Standards(standardsConfig);
|
||||
}
|
||||
else {
|
||||
this.calculator = new LevelCalculator(new Standards(standardsConfig));
|
||||
}
|
||||
this.appliedConfigStringified = standardsConfigStringified;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user