diff options
| author | amy <[email protected]> | 2025-04-14 14:09:22 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-14 14:09:22 -0500 |
| commit | dd7a8af4050454c3901987bff24a77334f892cc4 (patch) | |
| tree | 48c6107656e14cfbbcbb49424fc3454de850a5db /library | |
| parent | 44c68aa7d51ea6b50c442bfbfa4ce11c530d2f7d (diff) | |
| parent | dc7e4527e88ed0c59e17c0ff04c01e1c92136e42 (diff) | |
Merge pull request #1 from ameliasquires/new-config
updates how config values are updated, support for local values when copying states, and annotations
Diffstat (limited to 'library')
| -rw-r--r-- | library/lullaby.lua | 16 | ||||
| -rw-r--r-- | library/lullaby/array.lua | 56 | ||||
| -rw-r--r-- | library/lullaby/crypto.lua | 266 | ||||
| -rw-r--r-- | library/lullaby/error.lua | 3 | ||||
| -rw-r--r-- | library/lullaby/io.lua | 47 | ||||
| -rw-r--r-- | library/lullaby/math.lua | 10 | ||||
| -rw-r--r-- | library/lullaby/net.lua | 166 | ||||
| -rw-r--r-- | library/lullaby/test.lua | 11 | ||||
| -rw-r--r-- | library/lullaby/thread.lua | 67 |
9 files changed, 642 insertions, 0 deletions
diff --git a/library/lullaby.lua b/library/lullaby.lua new file mode 100644 index 0000000..9f66530 --- /dev/null +++ b/library/lullaby.lua @@ -0,0 +1,16 @@ +---@meta + +---@class lullaby +---@field version string +local lullaby = {} + +lullaby.crypto = require("library.lullaby.crypto") +lullaby.error = require("library.lullaby.error") +lullaby.io = require("library.lullaby.io") +lullaby.math = require("library.lullaby.math") +lullaby.net = require("library.lullaby.net") +lullaby.array = require("library.lullaby.array") +lullaby.test = require("library.lullaby.test") +lullaby.thread = require("library.lullaby.thread") + +return lullaby diff --git a/library/lullaby/array.lua b/library/lullaby/array.lua new file mode 100644 index 0000000..ebc23af --- /dev/null +++ b/library/lullaby/array.lua @@ -0,0 +1,56 @@ +---@meta + +---to be rewritten +---@deprecated +---@class lullaby.array +local table = {} + +---greatest, least +---@param array number[] +function table.quicksort(array) end + +---greatest, least +---@param array number[] +function table.mergesort(array) end + +---greatest, least +---@param array number[] +function table.shellsort(array) end + +---greatest, least +---@param array number[] +function table.bubblesort(array) end + +---greatest, least +---@param array number[] +function table.heapsort(array) end + +---least, greatest +---@param array integer[] +function table.countintsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function table.miraclesort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function table.stalinsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function table.slowsort(array) end + +---dont use this lol +---@deprecated +---greatest, least +---@param array number[] +function table.bogosort(array) end + +return table diff --git a/library/lullaby/crypto.lua b/library/lullaby/crypto.lua new file mode 100644 index 0000000..307619b --- /dev/null +++ b/library/lullaby/crypto.lua @@ -0,0 +1,266 @@ +---@meta + +---@class crypto +local crypto = {} + +---@class hash +---@operator add(string): hash +local hash = {} + +---@param T hash +---@param value string +function hash.update(T, value) end + +---@param T hash +function hash.final(T) end + +---@return hash +---@overload fun(value: string): string +function crypto.adler32() end + +---@return hash +---@overload fun(value: string): string +function crypto.bsdchecksum() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha0() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha1() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha256() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha224() end + +---@return hash +---@overload fun(value: string): string +function crypto.pearson() end + +---@param T integer[] +function crypto.setpearson(T) end + +---@param input string +---@return string +function crypto.xxh64(input) end + +---@param input string +---@return string +function crypto.xxh32(input) end + +---@return hash +---@overload fun(value: string): string +function crypto.crc8() end + +---@return hash +---@overload fun(value: string): string +function crypto.crc16() end + +---@return hash +---@overload fun(value: string): string +function crypto.crc32() end + +---@return hash +---@overload fun(value: string): string +function crypto.fletcher8() end + +---@return hash +---@overload fun(value: string): string +function crypto.fletcher16() end + +---@return hash +---@overload fun(value: string): string +function crypto.fletcher32() end + +---@return hash +---@overload fun(value: string): string +function crypto.sysvchecksum() end + +---@return hash +---@overload fun(value: string): string +function crypto.xor8() end + +---@param input string +---@return string +function crypto.buzhash8(input) end + +---@param input string +---@return string +function crypto.buzhash16(input) end + +---@param T integer[] +function crypto.setbuzhasah(T) end + +---@param input string +---@return string +function crypto.cityhash32(input) end + +---@param input string +---@return string +function crypto.cityhash64(input) end + +---@param input string +---@return string +function crypto.cityhash128(input) end + +---@return hash +---@overload fun(value: string): string +function crypto.md5() end + +---@return hash +---@overload fun(value: string): string +function crypto.djb2() end + +---@param input string +---@return string +function crypto.farmhash32(input) end + +---@param input string +---@return string +function crypto.farmhash64(input) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.fasthash32(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.fasthash64(input, seed) end + +---@return hash +---@overload fun(value: string): string +function crypto.fnv_0() end + +---@return hash +---@overload fun(value: string): string +function crypto.fnv_1() end + +---@return hash +---@overload fun(value: string): string +function crypto.fnv_a() end + +---@return hash +---@overload fun(value: string): string +function crypto.oaat() end + +---@return hash +---@overload fun(value: string): string +function crypto.loselose() end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.metrohash64_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.metrohash64_v2(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.metrohash128_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.metrohash128_v2(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.murmur1_32(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.murmur2_32(input, seed) end + +---@return hash +---@overload fun(value: string): string +function crypto.pjw() end + +---@return hash +---@overload fun(value: string): string +function crypto.sdbm() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha512() end + +---@return hash +---@overload fun(value: string): string +function crypto.sha384() end + +---@param t integer 0 < t <= 512 +---@return hash +---@overload fun(t, value: string): string +function crypto.sha512_t(t) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash128_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash128_v2(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash64_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash64_v2(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash32_v1(input, seed) end + +---@param input string +---@param seed integer | nil +---@return string +function crypto.spookyhash32_v2(input, seed) end + +---@return hash +---@overload fun(value: string): string +---@overload fun(value: string, length: integer, key: string): string +---@overload fun(length: integer, key: string): hash +function crypto.blake2b() end + +---@return hash +---@overload fun(value: string): string +---@overload fun(value: string, length: integer, key: string): string +---@overload fun(length: integer, key: string): hash +function crypto.blake2s() end + +---@return hash +---@overload fun(value: string): string +function crypto.blake256() end + +---@return hash +---@overload fun(value: string): string +function crypto.blake224() end + +---@return hash +---@overload fun(value: string): string +function crypto.blake512() end + +---@return hash +---@overload fun(value: string): string +function crypto.blake384() end + +return crypto diff --git a/library/lullaby/error.lua b/library/lullaby/error.lua new file mode 100644 index 0000000..1903746 --- /dev/null +++ b/library/lullaby/error.lua @@ -0,0 +1,3 @@ +---@meta + +---@alias error nil, any diff --git a/library/lullaby/io.lua b/library/lullaby/io.lua new file mode 100644 index 0000000..6e7eb9d --- /dev/null +++ b/library/lullaby/io.lua @@ -0,0 +1,47 @@ +---@meta + +---@class io +---@field filemallocchunk integer default chunk size for readfile +---@field print_type integer print the type next to the value +---@field max_depth integer max print depth before collapsing +---@field start_nl_at integer when to start new line while printing +---@field collapse_all integer whether or not to collapse everything +---@field collapse_to_memory integer when collapsing, print memory address +---@field print_meta integer print metatable +local io = {} + +---print a string with a "pretty" log header +---@param value string value to print +---@return nil +function io.log(value) end + +---print a string with a "pretty" warning header +---@param value string value to print +---@return nil +function io.warn(value) end + +---print a string with a "pretty" error header +---@param value string value to print +---@return nil +function io.error(value) end + +---print a string with a "pretty" debug header +---@param value string value to print +---@return nil +function io.debug(value) end + +---prints any value, expanding tables +---@param value any value to print +---@return nil +function io.pprint(value) end + +---@deprecated +function io.readfile() end + +---@deprecated +function io.json_parse() end + +---@deprecated +function io.arg_handle() end + +return io diff --git a/library/lullaby/math.lua b/library/lullaby/math.lua new file mode 100644 index 0000000..2914a56 --- /dev/null +++ b/library/lullaby/math.lua @@ -0,0 +1,10 @@ +---@meta + +---@class math +local math = {} + +---@param N number[] +---@return integer +function math.lcm(N) end + +return math diff --git a/library/lullaby/net.lua b/library/lullaby/net.lua new file mode 100644 index 0000000..3f9abdc --- /dev/null +++ b/library/lullaby/net.lua @@ -0,0 +1,166 @@ +---@meta + +---@class net +local net = {} + +---@class server-table +local server_table = {} + +---@class res-table +local res_table = {} + +---sends value to client and closes socket +---@param T res-table +---@param value string +function res_table.send(T, value) end + +---autosets Content-Type and sends contents of file to client and closes socket +---@param T res-table +---@param value string +function res_table.sendfile(T, value) end + +---sends value to client and doesn't close the socket +---@param T res-table +---@param value string +function res_table.write(T, value) end + +---closes socket +---@param T res-table +function res_table.close(T) end + +---prevents calling any other selected routes +---@param T res-table +function res_table.stop(T) end + +---key value table containing header values to be sent +res_table.header = {} + +---@class req-table +local req_table = {} + +---"roll" the request forward +---@param T req-table +---@param bytes integer | nil +function req_table.roll(T, bytes) end + +---list of parameters in route +req_table.parameters = {} + +---@deprecated +req_table.client_fd = 0 + +---@deprecated +req_table._bytes = 0 + +---@type integer +req_table.ip = 0 + +---@type string +req_table.Body = "" + +---@type any|nil +req_table.files = {} + +---@type any|nil +req_table.cookies = {} + + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.GET(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.HEAD(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.POST(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.PUT(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.DELETE(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.CONNECT(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.OPTIONS(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.TRACE(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.PATCH(T, route, callback) end + +---@param T server-table +---@param route string +---@param callback fun(res: res-table, req: req-table) +function server_table.all(T, route, callback) end + +---@param server server-table +local function listen_callback(server) end + +---@param callback fun(server: server-table) +---@param port integer +function net.listen(callback, port) end + +---creates an https request +---@param url string +---@param value string | nil +---@param header table<string, string> | nil +---@param request string | nil +---@return table<string, string> | error +function net.srequest(url, value, header, request) end + +---@class wss-table +local wss = {} + +---@class wss-read +local wss_read = {} + +---@type string +wss_read.content = "" + +---@type integer +wss_read.opcode = 0 + +---reads oldest unread frame from server +---@param T wss-table +---@return wss-read | error +function wss.read(T) end + +---sents data frame to server +---@param T wss-table +---@param data string +---@return nil | error +function wss.write(T, data) end + +---calls gc early +---@param T wss-table +---@return nil +function wss.close(T) end + +---creates a wss connection +---@param url string +---@return wss-table | error +function net.wss(url) end + +return net diff --git a/library/lullaby/test.lua b/library/lullaby/test.lua new file mode 100644 index 0000000..3bc7151 --- /dev/null +++ b/library/lullaby/test.lua @@ -0,0 +1,11 @@ +---@meta + +---not meant for normal usage +---@deprecated +---@class test +local test = {} + +function test._match() end +function test.stack_dump() end + +return test diff --git a/library/lullaby/thread.lua b/library/lullaby/thread.lua new file mode 100644 index 0000000..1b0e89d --- /dev/null +++ b/library/lullaby/thread.lua @@ -0,0 +1,67 @@ +---@meta + +---@class thread +local thread = {} + +---@class async-table +local async = {} + +---waits for thread to exit, returns the value of res +---@param T async-table +---@return ... +function async.await(T) end + +---calls thread __gc early +---@param T async-table +---@return nil +function async.clean(T) end + +---contains data for the thread +---@deprecated +---@type lightuserdata +async._ = nil + +---@async +---@param fun fun(res: fun(...)): nil function to call, parameter will set a return value for the thread +---@return async-table +function thread.async(fun) end + +---@class buffer-table +local buffer = {} + +---gets the value of the buffer +---@param T buffer-table +---@return any +function buffer.get(T) end + +---sets the value of the buffer +---@param T buffer-table +---@param value any +---@return nil +function buffer.set(T, value) end + +---calls a function with a parameter that is the value of the buffer, return the new value of the buffer +---@param T buffer-table +---@param fun fun(any): nil +---@return nil +function buffer.mod(T, fun) end + +---puts a value into a atomic thread-safe buffer +---@param value any +---@return buffer-table +function thread.buffer(value) end + +---locks any thread reaching this lock id until a corresponding unlock is met +---@param tid integer +---@return nil +function thread.lock(tid) end + +---unlocks a lock id +---@param tid integer +---@return nil +function thread.unlock(tid) end + +---@deprecated +function thread.testcopy() end + +return thread |
