JavaScript 在浏览器中执行脚本语言的库

JavaScript library that executes scripting language in browser

是否有一些 JS 库可以在浏览器环境中执行用其他脚本语言(如 Lua)编写的脚本。例如。像这样的东西。

TheLibabry.executeScript(scriptCode, apiObjects, timeout);

我知道 eval() 函数,但我需要在隔离环境中 运行 的脚本,即无法访问我的代码。我想要一些简单、经典的命令式语言,例如 Lua 甚至是基本的。另外,我希望能够为此脚本设置超时。 IE。限制执行时间。

您可以尝试利用 WebAssembly 运行 不同的代码语言。

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