config.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. interface ConfigInterface {
  2. [id: string]: unknown;
  3. }
  4. class ConfigObject implements ConfigInterface {
  5. public decimalPlaces: number;
  6. public intConvertRoundMode: number;
  7. public default_lang: string;
  8. public enable_type_casting: boolean;
  9. public idle_input_interval: number;
  10. public suspend_threshold: number;
  11. public max_instruction_count: number;
  12. [id: string]: unknown;
  13. constructor () {
  14. this.decimalPlaces = 8;
  15. this.intConvertRoundMode = 2;
  16. this.default_lang = "pt";
  17. this.enable_type_casting = true;
  18. this.idle_input_interval = 5000;
  19. this.suspend_threshold = 1000;
  20. // this.max_instruction_count = 350250; - automated evaluation limit
  21. this.max_instruction_count = Number.MAX_SAFE_INTEGER;
  22. }
  23. setConfig (opts: object): void {
  24. const otherConfig = opts as ConfigInterface;
  25. for (const key in otherConfig) {
  26. if (Object.prototype.hasOwnProperty.call(this, key)) {
  27. this[key] = otherConfig[key];
  28. }
  29. }
  30. }
  31. }
  32. const config = new ConfigObject();
  33. export const Config = config;