flua
Fengari is great, but if you're unfamiliar with Lua it's useless. It simply tells you to read the Lua C documentation and if you're brave enough to read that you'll end up not understanding anything about the Lua stack, pushing stuff to the stack and who knows what. There's a video that will teach you that in 40 minutes (or less if you accelerate it), but you may not that have these minutes. And you may not want to go to the trouble of converting JavaScript objects into Lua and vice-versa.
npm install flua
const flua = try let tojs = flua console // 30 catch e console
(When passing functions from JavaScript to Lua, you can make them return an array. In that case it will translate into a Lua function that returns multiple values. If you want a Lua function that returns an array-table instead of multiple values, return an array with your desired array inside.)
If you want more control, see example.js or read the source for runWithGlobals
.
Don't install fengari from npm. What you need is fengari-web. But since it doesn't work with Browserify you can include it with
and then you can use window.fengari
instead of require('fengari')
(on example.js I'm using a browserify shim).