Lua librarys in TypeScript

TypeScript implementations of 16 Lua standard library functions across 2 modules. Each function is individually importable and tree-shakeable.

math string

We have 16 Lua functions so far - help us add more

Got a rainy Sunday afternoon and a taste for a porting puzzle?

  • Get inspiration from the Lua 5.4 manual.
  • Click "New file" in the appropriate folder on GitHub. This will fork the project to your account, directly add the file to it, and send a Pull Request to us.

We will then review it. If it's useful to the project and in line with our contributing guidelines your work will become part of Locutus and you'll be automatically credited in the authors section accordingly.

Upstream Surface Inventory 16/157 shipped · 36 next 10%

Locutus tracks 11 upstream namespaces for Lua and sorts them into what is already shipped, what we still want, what we intentionally keep, and what still needs a decision.

This inventory now tracks Lua's core plain-value libraries plus the environment-facing standard tables, not the full host runtime.

10% catalog shipped
Shipped Next Explicit non-goals
string 41% math 29% utf8 0% os 0% table 0% _G 0% core 0% coroutine 0% debug 0% io 0% package 0%
Tracked namespaces 11
Shipped 16/157
Next to port 36
Explicit non-goals 105

In progress

string

Lua 5.4 · Catalog source: live runtime snapshot nickblah/lua:5.4-alpine:string

58% shipped
7/12 shipped 5 next 5 explicit non-goals
Shipped (7)

Next

Lua string helpers are strong plain-value portability targets.

  • byte
  • char
  • find
  • format
  • match
Explicit non-goals (5)
  • dump Skip Bytecode dumping is not a good security or portability target.
  • gmatch Skip Iterator-returning APIs do not fit Locutus' plain-value model.
  • pack Skip Binary packing semantics do not map cleanly to JS plain values.
  • packsize Skip Binary packing semantics do not map cleanly to JS plain values.
  • unpack Skip Binary packing semantics do not map cleanly to JS plain values.

math

Lua 5.4 · Catalog source: live runtime snapshot nickblah/lua:5.4-alpine:math

30% shipped
9/30 shipped 21 next 1 explicit non-goals
Shipped (9)

Next

Lua math helpers map cleanly to JS numbers.

  • acos
  • asin
  • atan
  • atan2
  • cosh
  • deg
  • exp
  • fmod
  • frexp
  • ldexp
  • log
  • log10
  • modf
  • pow
  • rad
  • random
  • sinh
  • tan
  • tanh
  • tointeger
  • ult
Explicit non-goals (1)
  • randomseed Skip Global RNG seeding mutates ambient runtime state.

utf8

Lua 5.4 · Catalog source: live runtime snapshot nickblah/lua:5.4-alpine:utf8

0% shipped
0/4 shipped 4 next 1 explicit non-goals

Next

UTF-8 codepoint helpers have a strong plain-value string and numeric contract.

  • char
  • codepoint
  • len
  • offset
Explicit non-goals (1)
  • codes Skip Iterator-returning APIs do not fit Locutus' current plain-value model.

os

Lua 5.4 · Catalog source: live runtime snapshot nickblah/lua:5.4-alpine:os

0% shipped
0/3 shipped 3 next 8 explicit non-goals

Next

Date formatting and decomposition still have a useful plain-value contract.

  • date

Time-difference helpers have a clean plain-value contract.

  • difftime

Unix-time conversion has a clean plain-value contract.

  • time
Explicit non-goals (8)
  • clock Skip Most os helpers depend on host environment, clocks, or filesystem state.
  • execute Skip Process spawning is outside Locutus' portability scope.
  • exit Skip Process termination is outside Locutus' value-only model.
  • getenv Skip Environment lookup depends on host runtime state.
  • remove Skip Filesystem mutation is outside Locutus' portability scope.
  • rename Skip Filesystem mutation is outside Locutus' portability scope.
  • setlocale Skip Locale mutation changes ambient runtime behavior.
  • tmpname Skip Temporary-path generation depends on host state.

table

Lua 5.4 · Catalog source: live runtime snapshot nickblah/lua:5.4-alpine:table

0% shipped
0/3 shipped 3 next 4 explicit non-goals

Next

String joining over list-like tables has a clean plain-value contract.

  • concat

Packing variadic values into a list-like table is a useful portability target.

  • pack

Table expansion still has a useful plain-value contract for parity and examples.

  • unpack
Explicit non-goals (4)
  • insert Skip Most table helpers mutate caller-owned tables rather than returning plain immutable values.
  • move Skip Most table helpers mutate caller-owned tables rather than returning plain immutable values.
  • remove Skip Most table helpers mutate caller-owned tables rather than returning plain immutable values.
  • sort Skip Most table helpers mutate caller-owned tables rather than returning plain immutable values.

Triaged as out of scope

_G Lua 5.4
0/0 24 skipped
core Lua 5.4
0/0 24 skipped
coroutine Lua 5.4
0/0 8 skipped
debug Lua 5.4
0/0 17 skipped
io Lua 5.4
0/0 11 skipped
package Lua 5.4
0/0 2 skipped