https://github.com/zeyu-li/lua-runner
A NPM package to run Lua 🌠with over 2.5k Downloads!
https://github.com/zeyu-li/lua-runner
lua lua-runner npm npm-module npm-package typescript webassembly
Last synced: 10 months ago
JSON representation
A NPM package to run Lua 🌠with over 2.5k Downloads!
- Host: GitHub
- URL: https://github.com/zeyu-li/lua-runner
- Owner: Zeyu-Li
- License: mit
- Created: 2021-03-27T20:21:46.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-16T19:23:40.000Z (about 3 years ago)
- Last Synced: 2025-04-14T03:54:55.175Z (10 months ago)
- Topics: lua, lua-runner, npm, npm-module, npm-package, typescript, webassembly
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/lua-runner
- Size: 158 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lua Runner
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/lua-runner) 
A node module that runs Lua code with the power of webassembly!
## About
Run your Lua code right inside of JavaScript or TypeScript with this module. Made from [wasm_lua](https://github.com/Dreagonmon/wasm_lua)
- [x] Lua 5.4.0
- [x] TypeScript support
- [x] 0 dependencies
- [x] Tests
- [ ] Browser support
## Installation
To install do
`npm i lua-runner --save`
## Usage
To use the module
```js
// 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
```js
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
```tsx
interface response {
return?: string
exit_code?: string
}
```
This function call is `run_lua_res` instead of run_lua
```js
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);
});
```
## Author
* [Zeyu Li](https://github.com/Zeyu-Li)
## License
[](https://www.lua.org/license.html)
License under MIT, check out Lua at [lua.org](https://www.lua.org/)