Skip to content

Commit 15f883e

Browse files
committed
Add small help section to README.md
1 parent 818d4cc commit 15f883e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,28 @@ changes to the original lua-getsize code:
2626
(the default), "u" will count Lua upvalues (the default), and "U"
2727
will _not_ count Lua upvalues. You can combine those options.
2828

29+
## Getting Started ##
30+
31+
32+
This module exports just one function:
33+
34+
```lua
35+
local getsize = require("getsize")
36+
```
37+
38+
Calling this function with a Lua value as argument will return the
39+
size of the value in bytes. For tables it will return the lengths of
40+
array and hash part as additional return values. For functions you can
41+
decide whether you want to include the sizes of the proto object
42+
and/or the upvalues.
43+
44+
```lua
45+
print(getsize(getsize)) # -> 64
46+
local function f() return getsize end
47+
print(getsize(f)) # -> 80
48+
print(getsize(f, "uP")) # -> 80
49+
print(getsize(f, "up")) # -> 264
50+
print(getsize(f, "UP")) # -> 40
51+
print(getsize({ 1, 2, 3, x = 4, y = 5 }) # -> 152 3 2
52+
```
53+

0 commit comments

Comments
 (0)