Move all annotation files into library/ folder (for LuaLS/LLS-Addons).

This commit is contained in:
Alexander Chibrikin
2025-10-07 22:31:30 +03:00
parent f354d6bd0c
commit 61337d5f3d
43 changed files with 0 additions and 0 deletions

35
library/lua_ext/math.lua Normal file
View File

@@ -0,0 +1,35 @@
--- @diagnostic disable: missing-return
--- Get the hypotenuse of a triangle with legs x and y. Useful for distance calculation.
---
--- @param x number
--- @param y number
---
--- @return number
function math.hypot(x, y) end
--- Get the sign of given number `x`.
--- - returns `-1`, `0` or `1`
--- - if the absolute value of x is within the tolerance or x is NaN, 0 is returned.
---
--- @param x number
--- @param tolerance? number default: `0.0`
---
--- @return number
function math.sign(x, tolerance) end
--- Returns the factorial of `x`.
---
--- @param x number
---
--- @return number
function math.factorial(x) end
--- Returns x rounded to the nearest integer.
--- - At a multiple of 0.5, rounds away from zero.
---
--- @param x number
---
--- @return number
function math.round(x) end

View File

@@ -0,0 +1,15 @@
--- @diagnostic disable: missing-return
--- e.g. `"a,b":split(",")` returns `{"a","b"}`
--- @param separator? string cannot be empty, default: `","`
--- @param include_empty? boolean default: `false`
--- @param max_splits? number if it's negative, splits aren't limited, default: `-1`
--- @param sep_is_pattern? boolean it specifies whether separator is a plain string or a pattern (regex), default: `false`
--- @return string[]
function string:split(separator, include_empty, max_splits, sep_is_pattern) end
--- Returns the string without whitespace pre- and suffixes
--- e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"`
--- @return string
function string:trim() end

77
library/lua_ext/table.lua Normal file
View File

@@ -0,0 +1,77 @@
--- @diagnostic disable: missing-return
--- Returns a deep copy of `table`
--- - strips metatables, but this may change in the future
---
--- @generic T: table
--- @param table T
---
--- @return T
function table.copy(table) end
--- Returns a deep copy of `table` with metatable copied.
--- - since `5.12`
--- - `table` can also be non-table value, which will be returned as-is
--- - preserves metatables as they are
--- @since 5.12
--- @generic T: table
--- @param table T
---
--- @return T
function table.copy_with_metatables(table) end
--- Returns the smallest numerical index containing the value `val` in the table list.
--- - Non-numerical indices are ignored.
--- - If `val` could not be found, `-1` is returned.
--- - `list` must not have negative indices.
---
--- @generic value
--- @param list value[]
--- @param val value
---
--- @return integer
function table.indexof(list, val) end
--- Returns the key containing the value val in the table table.
--- - If multiple keys contain `val`, it is unspecified which key will be returned.
--- - If `val` could not be found, `nil` is returned.
---
--- @generic key, value
--- @param table table<key, value>
--- @param val value
---
--- @return key?
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 other_table table
---
--- @return table<number,value>
function table.insert_all(table, other_table) end
--- Returns a table with keys and values swapped
--- - If multiple keys in `t` map to the same value, it is unspecified which value maps to that key.
---
--- @generic key, value
--- @param t table<key, value>
---
--- @return table<value, key>
function table.key_value_swap(t) end
--- Shuffles elements `from` to `to` in `table` in place (modifies exectly `table`, use `table.copy()` if needed).
--- * `from` defaults to `1`
--- * `to` defaults to `#table`
--- * `random_func` defaults to `math.random`. This function receives two
--- integers as arguments and should return a random integer inclusively
--- between them.
---
--- @param table table list to shuffle in.
--- @param from? integer (default: `1`)
--- @param to? integer (default: `#table`)
--- @param random_func? fun(min: integer, max: integer): integer (default: `math.random`) should return a random integer inclusively between `from` & `to`.
function table.shuffle(table, from, to, random_func) end