Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Leopard

Leopard is the fastest serializer for Lua 5.1.

Features

  • Function support.
  • Automatically escapes strings.
  • Simple and easy use.
  • Custom config support.
  • Human readable output.
  • Table compression.

Peformance

Test can be found in tests/test.lua.

  • leopard (10000): 0.72s
  • serpent (10000): 1.646s
  • Rochet2 (10000): 3.775s

API

Serialize

This function serializes table tbl and returns a string.

<string> Serialize(<table tbl>);

Serialize Compress

This function serializes and compresses table tbl and returns a string.

<string> SerializeCompress(<table tbl>);

Format Arguments

This function iterates through the passed arguments, formatting each value, then returns each value joined by , .

<string> FormatArguments(<... any>);

Format String

This function formats string str.

<string> FormatString(<string str>);

Update Config

This function allows you to edit the configuration used by the serializer

<void> UpdateConfig(<table { spaces = 4 }>);

Usage Example

local Serializer = require("leopard");
local function test(a, b, ...)
    print(a,b, ...);
end;

local Target = {
    1,
    true,
    test,
    "Hello World \7"
}

local Output = Serializer.Serialize(Target);
print(Output);

Output

{
    1,
    true,
    function(...) return loadstring("\27\76\117\97\81\0\1\4\4\4\8\0\12\0\0\0\64\46\92\116\101\115\116\46\108\117\97\0\2\0\0\0\4\0\0\0\0\2\3\7\6\0\0\0\197\0\0\0\0\1\0\0\64\1\128\0\165\1\0\0\220\64\0\0\30\0\128\0\1\0\0\0\4\6\0\0\0\112\114\105\110\116\0\0\0\0\0\6\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\4\0\0\0\3\0\0\0\2\0\0\0\97\0\0\0\0\0\5\0\0\0\2\0\0\0\98\0\0\0\0\0\5\0\0\0\4\0\0\0\97\114\103\0\0\0\0\0\5\0\0\0\0\0\0\0")(...); end,
    "Hello World \7"
}

Compression Example

local Serializer = require("leopard");
local function test(a, b, ...)
    print(a,b, ...);
end;

local Target = {
    1,
    true,
    test,
    "Hello World \7"
}

local Output = Serializer.SerializeCompress(Target);
print(Output);

Output

{1,true,function(...) return loadstring("\27\76\117\97\81\0\1\4\4\4\8\0\12\0\0\0\64\46\92\116\101\115\116\46\108\117\97\0\2\0\0\0\4\0\0\0\0\2\3\7\6\0\0\0\197\0\0\0\0\1\0\0\64\1\128\0\165\1\0\0\220\64\0\0\30\0\128\0\1\0\0\0\4\6\0\0\0\112\114\105\110\116\0\0\0\0\0\6\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\3\0\0\0\4\0\0\0\3\0\0\0\2\0\0\0\97\0\0\0\0\0\5\0\0\0\2\0\0\0\98\0\0\0\0\0\5\0\0\0\4\0\0\0\97\114\103\0\0\0\0\0\5\0\0\0\0\0\0\0")(...); end,"Hello World \7"}

About

The "fastest" serializer for Lua 5.1 and Roblox

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages