diff --git a/lua_ext/math.lua b/lua_ext/math.lua index ad35a51..faf2d36 100644 --- a/lua_ext/math.lua +++ b/lua_ext/math.lua @@ -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 diff --git a/lua_ext/string.lua b/lua_ext/string.lua index c17189d..8c0a06c 100644 --- a/lua_ext/string.lua +++ b/lua_ext/string.lua @@ -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 diff --git a/lua_ext/table.lua b/lua_ext/table.lua index f69ea32..169ce3c 100644 --- a/lua_ext/table.lua +++ b/lua_ext/table.lua @@ -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 +--- @param table table --- @param other_table table --- ---- @return table +--- @return table function table.insert_all(table, other_table) end