Purge unused dependencies. Update dependencies to latest except: - ts-lint. Keep locked to 9.0.1 because that's the latest version that works with Webpack 4 that's still used by vue-cli-plugin-electron-builder. - Keep eslint at version 7 because tests cannot be run/compiled with version 7, see eslint/eslint#15678, vuejs/vue-cli#6759. Newer versions of ESLint modules do not allow linebreak after or before = operator (operator-linebreak). This commit also changes files to comply with it. Closes #116, #119, #122, #130.
32 lines
879 B
TypeScript
32 lines
879 B
TypeScript
import { IEnumParser } from '@/application/Common/Enum';
|
|
|
|
export class EnumParserStub<T> implements IEnumParser<T> {
|
|
private readonly scenarios = new Array<{
|
|
inputName: string, inputValue: string, outputValue: T }>();
|
|
|
|
private defaultValue: T;
|
|
|
|
public setup(inputName: string, inputValue: string, outputValue: T) {
|
|
this.scenarios.push({ inputName, inputValue, outputValue });
|
|
return this;
|
|
}
|
|
|
|
public setupDefaultValue(outputValue: T) {
|
|
this.defaultValue = outputValue;
|
|
return this;
|
|
}
|
|
|
|
public parseEnum(value: string, propertyName: string): T {
|
|
const scenario = this.scenarios.find(
|
|
(s) => s.inputName === propertyName && s.inputValue === value,
|
|
);
|
|
if (scenario) {
|
|
return scenario.outputValue;
|
|
}
|
|
if (this.defaultValue) {
|
|
return this.defaultValue;
|
|
}
|
|
throw new Error('enum parser is not set up');
|
|
}
|
|
}
|