Actualize math, string, table helpers.

This commit is contained in:
Alexander Chibrikin
2026-02-02 04:59:11 +03:00
parent e21367325c
commit 1d0043bfe7
3 changed files with 47 additions and 2 deletions

View File

@@ -33,3 +33,10 @@ function math.factorial(x) end
---
--- @return integer
function math.round(x) end
--- Returns `true` if `x` is neither an infinity nor a NaN, and `false` otherwise.
---
--- @param x number
---
--- @return boolean
function math.isfinite(x) end

View File

@@ -13,3 +13,41 @@ function string:split(separator, include_empty, max_splits, sep_is_pattern) end
--- e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
--- @return string
function string:trim() end
--- Backported from Lua 5.4, see https://www.lua.org/manual/5.4/manual.html#6.4.2
---
--- Returns a binary string containing the values `v1`, `v2`, etc. packed (that
--- is, serialized in binary form) according to the format string `fmt`.
---
--- @param fmt string
--- @param v1 string
--- @param v2? string
--- @param ... string
---
--- @return string
function string.pack(fmt, v1, v2, ...) end
--- Backported from Lua 5.4, see https://www.lua.org/manual/5.4/manual.html#6.4.2
---
--- Returns the values packed in string `s` according to the format string
--- `fmt`. An optional `pos` marks where to start reading in `s` (default is 1).
--- After the read values, this function also returns the index of the first
--- unread byte in `s`.
---
--- @param fmt string
--- @param s string
--- @param pos? integer
---
--- @return any ...
--- @return integer offset
function string.unpack(fmt, s, pos) end
--- Backported from Lua 5.4, see https://www.lua.org/manual/5.4/manual.html#6.4.2
---
--- Returns the size of a string resulting from `string.pack` with the given
--- format. The format string cannot have the variable-length options '`s`' or '`z`'
---
--- @param fmt string
---
--- @return integer
function string.packsize(fmt) end

View File

@@ -47,10 +47,10 @@ function table.keyof(table, val) end
--- Appends all values in `other_table` to table - uses `#table + 1` to find new indices.
---
--- @generic value
--- @param table table<number, value>
--- @param table table<integer, value>
--- @param other_table table
---
--- @return table<number,value>
--- @return table<integer,value>
function table.insert_all(table, other_table) end