Serializes and deserializes Lua values with LuaJIT
Go to file
Jasmijn Wellner 4545391591 Release 1.2
It has been long overdue. Let's serialize the world!

Some important changes since 1.1:

- Can serialize metatables now (optionally disabled with `bitser.includeMetatables`)
- Added an extension API
- Removed support for cdata, which was just too buggy to hold on. More robust support would probably need to depend on ffi-reflect, which is best done by an extension library
2024-12-31 10:47:08 +01:00
cases Add ability to serialize metatables 2020-12-26 14:22:57 +01:00
examples Add an extension for #24 2024-12-29 19:33:44 +01:00
rockspecs Release 1.2 2024-12-31 10:47:08 +01:00
spec Release 1.2 2024-12-31 10:47:08 +01:00
.gitignore Add a test for rxi/classic 2024-12-29 17:54:42 +01:00
bitser.lua Release 1.2 2024-12-31 10:47:08 +01:00
conf.lua Close #13 2020-04-27 19:47:09 +02:00
EXTENSION_API.md Add initial version of the extension API 2021-03-30 17:14:14 +02:00
LICENSE.txt Release 1.2 2024-12-31 10:47:08 +01:00
main.lua Add ability to serialize metatables 2020-12-26 14:22:57 +01:00
README.md Mention support for Classic in documentation 2024-12-29 17:56:55 +01:00
setuptest.sh Test under LuaJIT 2.1 instead of 2.0 2024-12-30 16:09:26 +01:00
test.sh Update test.sh 2024-12-29 16:02:15 +01:00
USAGE.md Fix bug #33 by changing the contract 2024-12-31 10:36:41 +01:00

bitser

Serializes and deserializes Lua values with LuaJIT.

local bitser = require 'bitser'

bitser.register('someResource', someResource)
bitser.registerClass(SomeClass)

serializedString = bitser.dumps(someValue)
someValue = bitser.loads(serializedString)

Documentation can be found in USAGE.md.

Pull requests, bug reports and other feedback welcome! ❤️

Bitser is released under the ISC license (functionally equivalent to the BSD 2-Clause and MIT licenses).

Please note that bitser requires LuaJIT for its ffi library and JIT compilation. Without JIT, it may or may not run, but it will be much slower than usual. This primarily affects Android and iOS, because JIT is disabled on those platforms.

⚠️ bitser is not endian-safe. If you intend to share serialized data across computers, please make sure they share endianness making sure ffi.abi 'le' has the same value on both the sending and receiving machine, or use another serialization library.

Why would I use this?

Because it's fast. Because it produces tiny output. Because the name means "snappier" or "unfriendlier" in Dutch. Because it's safe to use with untrusted data.

Because it's inspired by binser, which is great.

How do I use the benchmark thingy?

Download zero or more of binser.lua, ser.lua, smallfolk.lua, serpent.lua and MessagePack.lua, and run:

love .

You do need LÖVE for that.

You can add more cases in the folder cases/ (check out _new.lua), and add other serializers to the benchmark in main.lua. If you do either of those things, please send me a pull request!

You can register classes?

Yes. At the moment, bitser supports classes created using MiddleClass, SECL, hump.class, Slither, Moonscript and Classic (and probably some other class libraries by accident).