2.0.3 • Published 4 years ago

lua-runner v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Lua Runner

License: MIT npm version download count badge

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

  • Lua 5.4.0
  • TypeScript support
  • 0 dependencies
  • Tests
  • Browser support

Installation

To install do

npm i lua-runner --save

Usage

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);
});

Author

License

License: MIT

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago