Skip to content

Commit 8048f3e

Browse files
committed
docs: Better example for ldump itself (closes #38)
1 parent ddd8357 commit 8048f3e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docs/api.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@ ldump(value: any) -> string
88

99
Serialize given value to a string, that can be deserialized via `load`
1010

11-
TODO another, simpler example
11+
### Example
12+
13+
```lua
14+
local upvalue = 42
15+
local world = {
16+
name = "New world",
17+
get_answer = function() return upvalue end,
18+
}
19+
20+
local serialized_data = ldump(world) -- serialize to a string
21+
local loaded_world = load(serialized_data)() -- deserialize the string
22+
```
23+
24+
See as a test at [/tests/test_use_case:12](/tests/test_use_case#L12)
1225

1326
### Example
1427

0 commit comments

Comments
 (0)