{"id":"anexpia/bufferencoder","name":"bufferencoder","scope":"anexpia","platform":"roblox","description":"A very efficient and simple-to-use encoder that turns tables into buffers.","version":"1.4.0","latest":"1.4.0","versions":["1.0.1","1.1.0","1.2.0","1.2.1","1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.4.0","1.0.0"],"license":"GPL-3.0","licenseRating":"unsafe","licenseCaveats":["Strong copyleft: shipping this in your game plausibly requires releasing your game's entire source under GPL-3.0. Not recommended for closed-source projects."],"licenseVerified":false,"dependencies":{},"integrity":"891478bbc4eefdc6e463b6ec9a9abec91aacd520131591c48428a125ea72e32b","likes":0,"downloads":0,"install":"forest install anexpia/bufferencoder","url":"https://forest.dev/p/roblox/anexpia/bufferencoder","files":"https://api.forest.dev/ai/package/roblox/anexpia/bufferencoder/files","readme":"<img src=\"icon.png\" alt=\"Icon of BufferEncoder\" width=\"200\" height=\"200\">\n\n# BufferEncoder\nA very efficient and simple-to-use encoder that turns tables into buffers.\\\nUnlike other buffer serializers, BufferEncoder doesn't require you to define the structure of the buffer, and it supports all datatypes you'd normally have in a table.\n\n# Features\n\n* Very optimized and space-efficient\n* Supports any type of table (array, dictionary, mixed), cyclic tables, and any value for keys in dictionaries\n* Supports encoding every datatype that you'd realistically put in a table\n* Can encode non-encodeable values into 2 bytes if registered beforehand using **encoder.enums.register()**\n* Deduplicates repeated tables, strings, numbers, vectors, and enumitems\n* Has simple encryption that relies on psuedo-random number generation\n* Fully typed\n\nList of all datatypes that can be encoded are in [this module](src/init.luau)\n\n# API\n### Encoder.write(table, writestart, writesettings) -> ( buffer, {any}? )\nConverts the given `table` into a buffer\\\nIf `writestart` is provided, table content writing will begin from the number provided in the buffer\n\n`writesettings` fields: {\n-    **allowdeduplication: boolean** -- attempt to deduplicate repeated values if enabled to reduce buffer size\n-    **allowreferences: boolean** -- if enabled, return a table containing the values it couldn't encode alongside the buffer.\n-    **shiftseed: number** -- the type bytes of values are shuffled using the seed.\n-    **rbxenum_behavior: \"full\" | \"compact\"** -- override for the default setting in settings module.\n-    **color3always6bytes: boolean** -- override for the default setting in settings module.\n\n}\n\n> [!WARNING]\n> If you really need to securely encrypt your buffer, do not rely on the shiftseed field of writesettings.\n\n---\n### Encoder.read(buffer, readstart, readsettings) -> { [any]: any }\nConverts the given `buffer` back into a table\\\nParameters should be consistent with **Encoder.write()** so that you don't encounter bugs\n\n`readsettings` fields: {\n-    **allowdeduplication: boolean** -- if the buffer was written with deduplication enabled, **this must be enabled.**\n-    **references: {any}** -- table of values that couldn't be encoded which is returned by encoder.write()\n-    **shiftseed: number** -- the type bytes of values are unshuffled using the seed.\n-    **rbxenum_behavior: \"full\" | \"compact\"** -- override for the default setting in settings module.\n-    **sanitize_nanandinf: boolean** -- override for the default setting in settings module.\n\n}\n\n---\n### Encoder.enums.register(name, value) -> any\nRegisters `value` to be encoded, even if it is normally not encode-able\\\nIf value is not provided, it returns userdata created using **newproxy()**\n\nThe byte used to register the name value pair is synced with the client, so the same value can be sent between client & server via a remote if the value is defined to be the same on both ends\n\n> [!CAUTION]\n> This errors if the value is already registered and for certain values such as booleans, 0, 1, -1, \"\", math.huge, and NaN\n\n---\n### Encoder.enums.remove(name)\nRemoves the name value pair from the custom value registry\n\n# Settings\nSettings can be changed by either changing them directly in the 'Settings' module or by adding the setting as an attribute in the module with the value you want\n\n* rbxenum_behavior (\"compact\" or \"full\") - Changes how enumitems are encoded, defaults to **'full'**.\\\nExact details of what each type does are inside [this module](src/init.luau)\n* color3always6bytes (boolean) - Sets whether Color3s are always encoded as float16 values, defaults to **false**.\n* serverclientsyncing (boolean) - Determines whether to sync EnumItems and custom values from server to client, defaults to **false**\n* sanitize_nanandinf (boolean) - Determines whether to turn NaN and math.huge into 0 when reading buffer content, defaults to **false**\\\n*This only sanitizes them for Numbers, Vectors, Rays, and CFrames.*\n\n# License\nBufferEncoder is licensed under the [GPL-3.0 License](LICENSE).\n\n","readmeTruncated":false}