definedFunctions.js 693 B

123456789101112131415161718192021222324
  1. import { LanguageService } from '../services/languageService';
  2. import {createInputFun, createOutputFun} from './lib/io';
  3. function valueToKey (value, object) {
  4. for (const key in object) {
  5. if(object.hasOwnProperty(key)){
  6. if (object[key] === value) {
  7. return key;
  8. }
  9. }
  10. }
  11. return null;
  12. }
  13. const funcsObject = {
  14. $read: createInputFun(),
  15. $write: createOutputFun()
  16. }
  17. export const LanguageDefinedFunction = Object.freeze({
  18. getMainFunctionName: () => LanguageService.getCurrentLangFuncs().main_function,
  19. getInternalName: (localName) => valueToKey(localName, LanguageService.getCurrentLangFuncs()),
  20. getFunction: (internalName) => funcsObject[internalName],
  21. });