{"id":16187302,"url":"https://github.com/fiatjaf/glua","last_synced_at":"2025-09-25T04:31:47.057Z","repository":{"id":75623707,"uuid":"87884728","full_name":"fiatjaf/glua","owner":"fiatjaf","description":"Maybe you should use https://github.com/fiatjaf/flua instead of this","archived":false,"fork":false,"pushed_at":"2019-08-07T22:11:54.000Z","size":1382,"stargazers_count":138,"open_issues_count":0,"forks_count":7,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-28T18:03:30.858Z","etag":null,"topics":["gopherjs","lua"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fiatjaf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-11T03:34:50.000Z","updated_at":"2024-01-04T16:13:06.000Z","dependencies_parsed_at":"2023-06-16T22:45:48.155Z","dependency_job_id":null,"html_url":"https://github.com/fiatjaf/glua","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"57b64f9607799766956983ffd3d6e94ef2d4beea"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiatjaf%2Fglua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiatjaf%2Fglua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiatjaf%2Fglua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiatjaf%2Fglua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fiatjaf","download_url":"https://codeload.github.com/fiatjaf/glua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234152694,"owners_count":18787672,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gopherjs","lua"],"created_at":"2024-10-10T07:21:17.213Z","updated_at":"2025-09-25T04:31:41.636Z","avatar_url":"https://github.com/fiatjaf.png","language":"Go","readme":"## glua [![npm badge](https://img.shields.io/npm/v/glua.svg)](https://www.npmjs.com/package/glua)\n\n`glua` is what happens when you compile https://github.com/J-J-J/goluajit, a Lua VM written in Go (based on https://github.com/yuin/gopher-lua), 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.\n\n### example:\n\n```js\nconst glua = require('glua')\n\nglua.run(`\n  print(12, 'lala', true)\n`) // will print these values\n\nvar result\n\nglua.runWithGlobals({\n  diff: function (a, b) {\n    return Math.abs(Math.abs(b) - Math.abs(a))\n  },\n  saveResult: function (value) {\n    result = value\n  }\n}, `\n  local a = 23\n  local b = 74\n  local difference = diff(a, b)\n  saveResult(difference)\n`)\n\nconsole.log('the result is: ', result)\n\nglua.runWithModules({\n  fooprinter: `\nlocal fooprinter = {}\n\nfunction fooprinter.print (foo)\n  print('foo value is: ', foo)\nend\n\nreturn fooprinter\n  `\n}, {\n  foo: 264857\n}, `\nlocal fooprinter = require('fooprinter')\nprint('printing foo...')\nfooprinter.print(foo)\n`)\n```\n\n### try it now\n\nVisit https://raw.githack.com/fiatjaf/glua/master/try.html and use your console.\n\n## how do I\n\n1. Return multiple values from a JavaScript function?\n\n  Return the special object `{_glua_multi: []}` with an array of the multiple values you want your function to return.\n\n2. Get values out from the Lua environment?\n\n  Call `.runWithGlobals` passing a function that takes the parameters from Lua and saves them to a JavaScript variable. It works.\n","funding_links":[],"categories":["Resources"],"sub_categories":["Compiles to JS, asm.js or WebAssembly for Browser"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiatjaf%2Fglua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiatjaf%2Fglua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiatjaf%2Fglua/lists"}