@luaut/lua
v3.0.0
Published
The Lua 5.1 standard library as luaut types, and the methods arrays and strings answer to
Readme
@luaut/lua
The Lua 5.1 standard library as luaut types: the base library (print,
pairs, pcall, string, math, table, os, coroutine, ...) and type
as an overload set that drives narrowing.
Only what Lua itself defines is here. typeof, buffer, bit32, utf8,
table.create, string.split and the rest of Luau's additions are in
@luaut/roblox — Luau is Roblox's language — which depends on
this package and extends it: a name declared in both keeps what this one gave
it.
It also gives arrays and strings their methods — names:filter(f),
text:trim() — as types (ArrayMethods<T>, StringMethods), as the Luau
behind them (runtime/), and as the lowering that connects the two
(lowering.mjs, which the compiler loads and asks what each call becomes). Nothing is attached to a table or to the string metatable, so they
work on any array.
const long = names:filter(function(n) return #n > 3 end):map(string.upper)
print(names:join(", "), names:indexOf("a"), text:trim(), text:startsWith("A"))Indices are Luau's: the first element is 1, indexOf and findIndex answer
nil rather than -1, slice takes an inclusive range (counting from the end
when given a negative), and sort takes Luau's comparator. push, pop,
shift, unshift, sort and reverse change the array they are called on;
the rest return a new one. A string's own Lua methods (upper, sub, gsub,
...) are typed here too and stay plain Luau calls.
Install it directly only for plain Lua 5.1. For Luau or Roblox, install
@luaut/roblox; it brings this along.
Needs luaut-parser 3.1 or later.
npm i -D @luaut/lua{ "types": ["lua"], "paths": {}, "sourceMap": null }