feature/upgrade #12

Merged
manuel merged 67 commits from feature/upgrade into master 2024-01-28 00:13:54 +01:00
Showing only changes of commit 86574e8616 - Show all commits

View file

@ -36,12 +36,7 @@ export class ConverterRegistryService {
}
public getConverter(id: string): Converter {
for (let i = 0; i < this.converters.length; i++) {
if (this.converters[i].getId() === id) {
return this.converters[i];
}
}
return undefined;
return this.converters.find((converter: Converter): boolean => converter.getId() === id);
}
private init(): void {
@ -67,11 +62,11 @@ export class ConverterRegistryService {
}
private registerConverter(converter: Converter): void {
this.converters.forEach((c: Converter) => {
if (c.getId() === converter.getId()) {
throw new Error('Converter-ID ' + converter.getId() + ' is already registered!');
}
});
// Don't allow duplicate registration of the same converter id
if (this.converters.some((c: Converter): boolean => c.getId() === converter.getId())) {
throw new Error(`Converter-ID ${converter.getId()} is already registered!`);
}
this.converters.push(converter);
}
}