blob: 78f36925dbe021d8606745b18bbdf6a255e76fa5 [file] [log] [blame]
Adrià Vilanova Martínezad696762024-05-25 19:32:36 +02001import {
2 OptionCodename,
3 OptionsValues,
4 optionCodenames,
5} from './optionsPrototype';
6
7/**
8 * Representation of a specific configuration of the option values.
9 */
10export class OptionsConfiguration {
11 constructor(public optionsValues: OptionsValues) {}
12
13 getOptionValue<O extends OptionCodename>(option: O): OptionsValues[O] {
14 return this.optionsValues[option];
15 }
16
17 isEnabled(option: OptionCodename): boolean {
18 const value = this.getOptionValue(option);
19 return value === true;
20 }
21
22 isEqualTo(otherConfiguration: OptionsConfiguration) {
23 for (const option of optionCodenames) {
24 const thisValue = this.getOptionValue(option);
25 const otherValue = otherConfiguration.getOptionValue(option);
26 if (thisValue !== otherValue) {
27 return false;
28 }
29 }
30 return true;
31 }
32}