diff options
| author | ame <[email protected]> | 2023-12-19 11:38:17 -0600 |
|---|---|---|
| committer | ame <[email protected]> | 2023-12-19 11:38:17 -0600 |
| commit | 0112e2609f8aceb791656d19db568d04c586d7be (patch) | |
| tree | b130d479b882b903da691164f82557163c7dc048 /docs | |
| parent | 9a4d5574a89c4a7842211238d8b9b30b905cc056 (diff) | |
some docs:3
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/crypto.md | 79 | ||||
| -rw-r--r-- | docs/io.md | 43 | ||||
| -rw-r--r-- | docs/math.md | 13 | ||||
| -rw-r--r-- | docs/table.md | 115 |
4 files changed, 250 insertions, 0 deletions
diff --git a/docs/crypto.md b/docs/crypto.md new file mode 100644 index 0000000..68c6341 --- /dev/null +++ b/docs/crypto.md @@ -0,0 +1,79 @@ +# crypto + +## hashing + +\* is optional + +|name|out len|arg 2|extra| +|--|--|--|--| +| sha0 | 160 | nil | insecure, use sha1| +| sha1 | 160 | nil | | +| sha256 | 256 | nil | | +| sha224 | 224 | nil | | +| pearson | 8 | nil | use setpearson(table) to change the table, initial is 0..255| +| xxh64 | 64 | nil | xxhash | +| xxh32 | 32 | nil | | +| crc8 | 8 | nil | | +| crc16 | 16 | nil | | +| crc32 | 32 | nil | | +| fletcher8 | 8 | nil | | +| fletcher16 | 16 | nil | | +| fletcher32 | 32 | nil | | +| sysvchecksum | 32 | nil | | +| xor8 | 8 | nil | | +| buzhash8 | 8 | nil | use setbuzhash(table) to change table (will affect all buzhash functions) | +| buzhash16 | 16 | nil | ^ | +| cityhash32 | 32 | nil | | +| cityhash64 | 64 | nil | | +| cityhash128 | 128 | nil | | +| md5 | 128 | nil | | +| djb2 | 64 | nil | | +| farmhash32 | 32 | nil | | +| farmhash64 | 64 | nil | | +| fasthash32 | 32 | *seed | | +| fasthash64 | 64 | *seed | | +| fnv_0 | 64 | nil | | +| fnv_1 | 64 | nil | | +| fnv_a | 64 | nil | | +| oaat | 32 | nil | | +| lostlose | 64 | nil | | +| metrohash64_v1 | 64 | *seed | | +| metrohash64_v2 | 64 | *seed | | +| metrohash128_v1 | 128 | *seed | | +| metrohash128_v2 | 128 | *seed | | +| murmur1_32 | 32 | *seed | | +| murmur2_32 | 32 | *seed | | +| pjw | 32 | *seed | | +| sdbm | 64 | nil | | +| sha512 | 512 | nil | | +| sha384 | 384 | nil | | +| sha512_t | length of arg 2 | t (bit length) | bit length range is 0 < t <= 512 (this isnt checked, and it should accept any value) | +| spookyhash128_v1 | 128 | *seed | | +| spookyhash128_v2 | 128 | *seed | | +| spookyhash64_v1 | 64 | *seed | | +| spookyhash64_v1 | 64 | *seed | | +| spookyhash32_v1 | 32 | *seed | | +| spookyhash32_v1 | 32 | *seed | | + +### usage + +```lua +llib.crypto.sha512("meow") -- e88348269bad036160f0d9558b7c5de68163b50e1a6ce46e85ee64692eba074529a4a2b48db4d5c36496e845001e13e6d07c585eacd564defcbf719ec9033e17 +llib.crypto.sha512_t("meow", 224) -- would be sha512/224 - ad5e403e0d74532187f4e1665c7e705ab5eb3c2fe07ae73a3ff998b2 +``` + +## en/decoding + +all functions have 1 argument which is a string, unless noted otherwise + +|name|encode|decode|notes| +|--|--|--|--| +|uuencode|uuencode|uudecode| | +|base64|base64encode|base64decode| | + +### usage + +```lua +llib.crypto.base64encode("purr") -- cHVycg== +llib.crypto.base64decode("cHVycg==") -- purr +``` diff --git a/docs/io.md b/docs/io.md new file mode 100644 index 0000000..d009c8d --- /dev/null +++ b/docs/io.md @@ -0,0 +1,43 @@ +# io + +## common + +### pprint + +'accepts (probably) anything + +formats input as a readable string + +```lua +llib.io.pprint({a = 5, b = {9, 9, 22}}) +``` + +#### config options + +- print_type (0) - whether or not to print item type (0 or 1) +- max_depth (2) - maximum depth that will not be collapsed +- start_nl_at (3) - maximum depth that will be kept in-line + +### error/warn/log/debug + +'accepts a string + +outputs a fancy string (color!!!!) + +```lua +llib.io.log("meow") +``` + +### readfile + +'accepts a file path + +returns the content of that file as a string + +```lua +llib.io.readfile("./docs/io.md") -- (this file) +``` +#### config options + +- file_chunksize (512) - size of chunk to be allocated + diff --git a/docs/math.md b/docs/math.md new file mode 100644 index 0000000..0a84a8a --- /dev/null +++ b/docs/math.md @@ -0,0 +1,13 @@ +# math + +## common + +### lcm + +'accepts table of numbers + +returns lcm of given array + +```lua +llib.math.lcm({5, 4, 3}) -- 60 +``` diff --git a/docs/table.md b/docs/table.md new file mode 100644 index 0000000..e58dd54 --- /dev/null +++ b/docs/table.md @@ -0,0 +1,115 @@ +# table (tables and sorting) + +## sorting + +|name|accepted types|type of sorting|order| +|---|---|---|---| +|quicksort| double,int | comparison | greatest -> least | +|mergesort| double,int | comparison | greatest -> least | +|shellsort| double,int | comparison | greatest -> least | +|bubblesort| double,int | comparison | greatest -> least | +|heapsort| double,int | comparison | greatest -> least | +|countingsort| int | non-comparison | least -> greatest| +|miraclesort| double,int | esoteric | ? greatest -> least | +|stalinsort| double,int | esoteric | greatest -> least | +|slowsort| double,int | esoteric | greatest -> least | +|bogosort| double,int | esoteric | greatest -> least | + +### usage + +```lua +local test = {5, 10, 922, -32, 554, 0}; +locla test_sorted = llib.array.mergesort(test); -- 922, 554, 10, 5, 0, -32 +``` + +## utils + +### len + +'accepts any table + +returns length of table, including associative arrays + +```lua +llib.array.len({a = 55, b = 22}); -- 2 +``` + +### reverse + +'accepts any table + +reverses a table + +```lua +llib.array.reverse({5, 4, 22}) -- 22, 4, 5 +``` + +### least/greatest + +'accepts a table with numbers + +gets smallest/largest value of a table + +```lua +llib.array.greatest({22, 99, 99.9}) -- 99.9 +``` + +### shuffle + +'accepts any table + +randomizes array + +```lua +llib.array.shuffle({5, 22, 89}) -- 22, 89, 5 +``` +### sum + +'accepts a table with numbers + +gets sum of each element in a table + +```lua +llib.array.sum({5, 4, 3}) --12 +``` + +### index + +'accepts any table and a value + +gets index of item in array linearly, returns -1 if not present + +```lua +llib.array.index({5, 4, 3}, 4) -- 2 +``` + +### sindex + +'accepts a sorted table with numbers and a value + +gets index through binary search, -1 if not present + +```lua +llib.array.sindex({2, 4, 8}, 8) -- 3 +``` + +### split + +'accepts a string and a delimiter + +splits a string by arg2, returns a array + +```lua +llib.array.split("hello world"," ") -- "hello", "world" +``` + +### to_char_array + +'accepts a string + +returns a char array from a string + +```lua +llib.array.to_char_array("meow") -- "m", "e", "o", "w" +``` + |
