add unpack function documentation

This commit is contained in:
MihailRis
2024-12-27 09:58:02 +03:00
parent ee26b2a2b9
commit 72394181c7
3 changed files with 15 additions and 13 deletions
+8 -9
View File
@@ -39,6 +39,12 @@ Value characters describe the type and size.
> [!WARNING]
> Due to the absence of an integer type in Lua for values `l` and `L`, only an output size of 8 bytes is guaranteed; the value may differ from what is expected.
```lua
byteutil.unpack(format: str, bytes: table|Bytearray) -> ...
```
Extracts values from a byte array based on a format string.
Example:
```lua
@@ -58,14 +64,7 @@ debug.print(byteutil.tpack('>iBH?', -8, 250, 2019, true))
-- )
local bytes = byteutil.pack('>iBH?', -8, 250, 2019, true)
debug.print(byteutil.unpack('>iBH?', bytes))
print(byteutil.unpack('>iBH?', bytes))
-- outputs:
-- debug.print(
-- {
-- -8,
-- 250,
-- 2019,
-- true
-- }
--)
-- -8 250 2019 true
```