config.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 = 100;
  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;