1

Is there some JS library that could execute script written in some other scripting language (like Lua) in a browser environment. E.g. something like this.

TheLibabry.executeScript(scriptCode, apiObjects, timeout);

I know about eval() function, but I need a script to run in isolated environment i.e. do not have access to my code. And I want some simple, classic imperative language like Lua or even basic. Also, I want to be able to set a timeout for this script. I.e. limit execution time.

2
  • Writing a compiler from scratch in JS could be a good idea. Given that you don't have to worry about memory stuff and the parsing can be delegated to Peg.js or similar, that isn't as scary as it sounds. Commented Mar 9, 2018 at 14:42
  • I am not sure I am ready to write one more compiler right now. Commented Mar 9, 2018 at 16:26

1 Answer 1

3

You could try leveraging WebAssembly to run different code languages.

Wasm Lua

https://github.com/vvanders/wasm_lua

Docs for web assembly

https://developer.mozilla.org/en-US/docs/WebAssembly

Available langs in Web Assembly

https://github.com/appcypher/awesome-wasm-langs

https://medium.freecodecamp.org/get-started-with-webassembly-using-only-14-lines-of-javascript-b37b6aaca1e4

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.