config.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. public activity_programming_type: Map<string, string>;
  13. public activity_functions: Map<string, boolean>;
  14. public activity_datatypes: Map<string, boolean>;
  15. public activity_commands: Map<string, boolean>;
  16. public activity_filter: Map<string, boolean>;
  17. [id: string]: unknown;
  18. constructor () {
  19. this.decimalPlaces = 8;
  20. this.intConvertRoundMode = 2;
  21. this.default_lang = "pt";
  22. this.enable_type_casting = true;
  23. this.idle_input_interval = 5000;
  24. this.suspend_threshold = 1000;
  25. // this.max_instruction_count = 350250; - automated evaluation limit
  26. this.max_instruction_count = Number.MAX_SAFE_INTEGER;
  27. this.activity_programming_type = new Map<string, string>();
  28. this.activity_functions = new Map<string, boolean>();
  29. this.activity_datatypes = new Map<string, boolean>();
  30. this.activity_commands = new Map<string, boolean>();
  31. this.activity_filter = new Map<string, boolean>();
  32. }
  33. setConfig (opts: object): void {
  34. const otherConfig = opts as ConfigInterface;
  35. for (const key in otherConfig) {
  36. if (Object.prototype.hasOwnProperty.call(this, key)) {
  37. this[key] = otherConfig[key];
  38. }
  39. }
  40. }
  41. }
  42. const config = new ConfigObject();
  43. export const Config = config;