aboutsummaryrefslogtreecommitdiff
path: root/library/lullaby
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2025-03-31 13:21:27 -0500
committeramelia squires <[email protected]>2025-03-31 13:21:27 -0500
commit876e28e4dc4a6f2c19dc2523f5db78fa6e4a16a9 (patch)
treed1adb6a4e3cdf9ae3c11920ac98d4ed54bae8cca /library/lullaby
parent19cb409b0aee4b8605977644d8941460c02cdf80 (diff)
type definitions
Diffstat (limited to 'library/lullaby')
-rw-r--r--library/lullaby/crypto.lua266
-rw-r--r--library/lullaby/error.lua3
-rw-r--r--library/lullaby/io.lua40
-rw-r--r--library/lullaby/math.lua10
-rw-r--r--library/lullaby/net.lua166
-rw-r--r--library/lullaby/sort.lua54
-rw-r--r--library/lullaby/table.lua8
-rw-r--r--library/lullaby/test.lua11
-rw-r--r--library/lullaby/thread.lua67
9 files changed, 625 insertions, 0 deletions
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..4fb7768
--- /dev/null
+++ b/library/lullaby/io.lua
@@ -0,0 +1,40 @@
+---@meta
+
+---@class io
+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/sort.lua b/library/lullaby/sort.lua
new file mode 100644
index 0000000..c7d9f4d
--- /dev/null
+++ b/library/lullaby/sort.lua
@@ -0,0 +1,54 @@
+---@meta
+
+---@class sort
+local sort = {}
+
+---greatest, least
+---@param array number[]
+function sort.quicksort(array) end
+
+---greatest, least
+---@param array number[]
+function sort.mergesort(array) end
+
+---greatest, least
+---@param array number[]
+function sort.shellsort(array) end
+
+---greatest, least
+---@param array number[]
+function sort.bubblesort(array) end
+
+---greatest, least
+---@param array number[]
+function sort.heapsort(array) end
+
+---least, greatest
+---@param array integer[]
+function sort.countintsort(array) end
+
+---dont use this lol
+---@deprecated
+---greatest, least
+---@param array number[]
+function sort.miraclesort(array) end
+
+---dont use this lol
+---@deprecated
+---greatest, least
+---@param array number[]
+function sort.stalinsort(array) end
+
+---dont use this lol
+---@deprecated
+---greatest, least
+---@param array number[]
+function sort.slowsort(array) end
+
+---dont use this lol
+---@deprecated
+---greatest, least
+---@param array number[]
+function sort.bogosort(array) end
+
+return sort
diff --git a/library/lullaby/table.lua b/library/lullaby/table.lua
new file mode 100644
index 0000000..f02c21e
--- /dev/null
+++ b/library/lullaby/table.lua
@@ -0,0 +1,8 @@
+---@meta
+
+---to be rewritten
+---@deprecated
+---@class lullaby.table
+local table = {}
+
+return table
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