用于nodejs和浏览器功能齐全的Lua VM
用于nodejs和浏览器功能齐全的Lua VM
Go 其它杂项
共142Star
详细介绍
glua
glua
is what happens when you compile https://github.com/yuin/gopher-lua, a Lua VM written in Go, to Javascript. It works right now and you can use it for most awesomeness. You don't have to know Go or even click on the link above, just use this library in your favorite JS environment.
example:
const glua = require('glua')
glua.run(`
print(12, 'lala', true)
`) // will print these values
var result
glua.runWithGlobals({
diff: function (a, b) {
return Math.abs(Math.abs(b) - Math.abs(a))
},
saveResult: function (value) {
result = value
}
}, `
local a = 23
local b = 74
local difference = diff(a, b)
saveResult(difference)
`)
console.log('the result is: ', result)
try it now
Visit https://rawgit.com/fiatjaf/glua/master/try.html and use your console.