Registry / serialization / lua2js

lua2js

JSON →
library0.0.11jsnpmunverified

A Lua parser and transpiler to JavaScript that generates Mozilla Parser API ASTs. The current version is 0.0.11, with no recent releases or active development evident. It targets Lua 5.1 with partial support and aims to run unmodified Lua programs in JavaScript environments. Unlike other Lua transpilers, it provides options for Lua-JS interop such as automatic conversion of LuaTable to arrays/objects and method call syntax remapping. It requires no runtime dependencies and is distributed as a single minified file. The project has significant gaps: many standard library functions (e.g., string.format, pattern matching, coroutines, debug) are missing, and certain Lua syntax features (expression table keys, goto) are unsupported. The repository appears to be in maintenance or abandoned state.

serializationdata
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Default import is the parser object. CommonJS require also works.

import lua2js from 'lua2js'

Named export for the parse function.

import { parse } from 'lua2js'

Named export for the translate function.

import { translate } from 'lua2js'

Parses a Lua Fibonacci function and translates it to JavaScript, demonstrating basic usage of parse and translate.

import lua2js from 'lua2js'; const luaCode = ` function fib(n) if n < 2 then return n else return fib(n-1) + fib(n-2) end end print(fib(10)) `; const ast = lua2js.parse(luaCode); const jsCode = lua2js.translate(ast); console.log(jsCode); // Output: // var fib = function(n) { // if (n < 2) { // return n; // } else { // return fib(n - 1) + fib(n - 2); // } // }; // console.log(fib(10));
lua2js --version
Debug
Known footguns
breakingLua standard library functions like string.format, pattern matching, coroutines, and debug are missing.
gotchaExpression table keys (e.g., {[expr]=value}) are not supported.
breakingLong form strings with internal ]] may cause parse errors even with [==[ syntax.
deprecatedThe project has no recent releases since 2014 and may be abandoned.
gotchaThe global environment _ENV and _G are not supported; globals are defined as properties of the global object.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
3
ahrefsbot
3
claudebot
3
Resources