{"id":"karl1229idk/ttb","name":"ttb","scope":"karl1229idk","platform":"roblox","description":"Mirrored from the Wally registry.","version":"1.1.1","latest":"1.1.1","versions":["1.1.1"],"license":"MPL-2.0","licenseRating":"caution","licenseCaveats":["File-level copyleft: if you modify this package's own source files, those modified files must be made available under MPL-2.0. Using it unmodified in a closed-source game is fine.","The package archive does not include its license text; the license is declared in its manifest metadata."],"licenseVerified":false,"dependencies":{},"integrity":"ae7597d2dff41b85bad3ecd19ed31e2ba322a68c009f9d6cf5a519139296c6f6","likes":0,"downloads":0,"install":"forest install karl1229idk/ttb","url":"https://forest.dev/p/roblox/karl1229idk/ttb","files":"https://api.forest.dev/ai/package/roblox/karl1229idk/ttb/files","readme":"<!--\r\nSPDX-FileCopyrightText: 2026 karl_dev1229 <karl1229idk@gmail.com>\r\n\r\nSPDX-License-Identifier: MPL-2.0\r\n-->\r\n# transform_table_buffer (TTB)\r\nHigh performance Roblox serializer to seamlessly transform ```array/hashmap``` <-> ```buffer```\\\r\n[![REUSE status](https://api.reuse.software/badge/codeberg.org/karl_dev1229/ttb)](https://api.reuse.software/info/codeberg.org/karl_dev1229/ttb)\r\n\r\n## Why TTB & TTBW?\r\n- **Minimal Buffer:** size = (1 + element bytes)\r\n- **Zero-Dependency:** download it, and plug-and-play\r\n- **Dynamic Typed:** no need to wait for IDL compile, which slow down the development process\r\n- **Type Infer:** you don't need to pass in type name, feel free to skip it\r\n- **Explicit Typing:** you can force TTB to use a type you want, for example, u8 instead of f64(default)\r\n- **HashMap Support:** support HashMap for lazy-devs, don't need to transform to array first\r\n- **Safety with TTBW:** TTBW guarantee the TTB to not crash\r\n\r\n## Supported Types\r\n| Types | Size (bytes) | Notes\r\n| :--- | :--- | :--- |\r\n| number / f64 | 8 | Standard Luau number type |\r\n| string |  2 + N | Length-prefixed (max 64KB) |\r\n| CFrame | 48 | Complete lossless CFrame |\r\n| f32 | 4 | 32 bit float |\r\n| u8 | 1 | Unsigned 8 bit integer |\r\n| u16 | 2 | Unsigned 16 bit integer |\r\n| i32 | 4 | Signed 32 bit integer |\r\n| Vector3 | 12 | Raw float packing |\r\n| Vector2 | 8 | Raw float packing |\r\n| Color3 | 3 | Compressed |\r\n| Color3F | 12 | Uncompressed |\r\n| boolean | 1 | 7-bit aligned |\r\n\r\n## Disclaimer\r\n***Safety is guaranteed by **YOU**, not the <ins>library</ins>!***\r\n- **No Nesting:** TTB is designed for flat data streams, it is *unsupported* and will *never* be supported\r\n- **Strict Type:** Passing unsupported type or wrong argument will be resulted in undefined behavior/crash\r\n- **Hashmap Rule:** Key must be string (max 255 bytes), Max 65535 pairs per map\r\n\r\n## TTBW: The offical TTB wrapper\r\nIf you are processing data from **untrusted source**, TTBW will be your best friend!\r\n- **Crash Preventation:** Prevent hard errors/terminations from malformed buffers\r\n- **Validation:** Perform boundary checks/type checkings before TTB execute\r\n- **Usage:** Always check if return value is ```nil```. ```nil``` indicates corrupted or malformed data\r\n\r\n## Usage\r\n### TTB Serialization\r\n```lua\r\nlocal ttb = require(\"path/to/TTB\")\r\nlocal data = { Vector3.new(1, 2, 3), Vector3.new(1, 2, 3) }\r\nlocal buf = ttb.getBufferFromArray(\r\n    data --,\r\n    --\"Vector3\" -- Feel free to not pass in type\r\n                -- TTB will infer it for you!\r\n)\r\n\r\nlocal decoded = ttb.decode(buf)\r\nassert(data[1] == decoded[1] and decoded[2] == data[2])\r\n\r\nlocal map = { player1 = 10, player2 = 20 }\r\nlocal buf = ttb.getBufferFromHashmap(\r\n    map,\r\n    \"u8\" -- u8, u16, i32, f32, f64 are supported\r\n         -- Without telling, TTB assume f64 for numbers\r\n)\r\nlocal decoded = ttb.decode(buf)\r\nassert(map.player1 == decoded.player1 and decoded.player2 == map.player2)\r\n```\r\n### TTBW Serialization\r\n```lua\r\nlocal ttbw = require(\"path/to/TTB/TTBW\")\r\nlocal decoded = ttbw.safeDecode(receivedBuffer)\r\n\r\nif decoded then\r\n    print(\"Processing\")\r\nelse\r\n    warn(\"Corrupted/Malformed buffer detected\")\r\nend\r\n```\r\n\r\n## License\r\nLicensed under [MPL-2.0](https://www.mozilla.org/MPL/2.0/)\\\r\n[REUSE 3.3](https://reuse.software/spec-3.3/) compliant\r\n\r\n## Zen of TTB\r\n- Do one thing and do it well\r\n- Explicit > Implicit\r\n- **Performance > DRY**\r\n- Safety belongs to users\r\n","readmeTruncated":false}