A node module that runs Lua code with the power of webassembly!
Run your Lua code right inside of JavaScript or TypeScript with this module. Made from wasm_lua
- Lua 5.4.0
- TypeScript support
- 0 dependencies
- Tests
- Browser support
To install do
npm i lua-runner --save
To use the module
// import the package
import {run_lua} from "lua-runner"
// define the lua code
let testLuaCode = `
function hello_lua()
print("Hello World!")
return "A"
end
return hello_lua()
`
// run the code with the run_lua function and use then to catch the response
run_lua(testLuaCode).then(res=> {
console.log(res)
})
or without ES6 syntax as
let { run_lua } = require("lua-runner");
let testLuaCode = `
function hello_lua()
print("Hello World!")
return "A"
end
return hello_lua()
`;
run_lua(testLuaCode).then(function (res) {
console.log(res);
});
lua runner also has a function that returns a response object in the form of the following
interface response {
return?: string
exit_code?: string
}
This function call is run_lua_res
instead of run_lua
let { run_lua_res } = require("lua-runner");
let testLuaCode = `
function hello_lua()
print("Hello World!")
return "A"
end
return hello_lua()
`;
run_lua_res(testLuaCode).then(function (res) {
console.log(res);
});
License under MIT, check out Lua at lua.org