wip
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
-- Private -----------------------------------------------------------------------------------------
|
||||
|
||||
local private = {}
|
||||
|
||||
function private.dump(value, depth, indent, seen)
|
||||
depth = depth or -1
|
||||
indent = indent or ""
|
||||
seen = seen or {}
|
||||
|
||||
if depth == 0 then return "<too deep: "..tostring(value)..">" end
|
||||
|
||||
if seen[value] == true then return "<already seen: "..tostring(value)..">" end
|
||||
seen[value] = true
|
||||
|
||||
local result = ""
|
||||
if type(value) == "table" then
|
||||
result = result.."{\n"
|
||||
local inner_indent = indent.." "
|
||||
for inner_key, inner_value in pairs(value) do
|
||||
local inner_text = private.dump(inner_value, depth - 1, inner_indent, seen)
|
||||
result = result..inner_indent..inner_key.." = "..inner_text.."\n"
|
||||
end
|
||||
result = result..indent.."}"
|
||||
else
|
||||
result = tostring(value)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
-- Export -----------------------------------------------------------------------------------------
|
||||
|
||||
return private.dump
|
||||
Reference in New Issue
Block a user