Rename dumpTable to dump and make it work with any values

This commit is contained in:
2025-05-20 20:40:25 +02:00
parent 26e783ee2e
commit 8532db5a25
22 changed files with 472 additions and 467 deletions

View File

@@ -1,25 +1,29 @@
local _, shared = ...
---@cast shared HeimdallShared
if not shared.dumpTable then
---@param table table
if not shared.dump then
---@param value any
---@param msg string?
---@param depth number?
shared.dumpTable = function(table, msg, depth)
if not table then
print(tostring(table))
shared.dump = function(value, msg, depth)
if not value then
print(tostring(value))
return
end
if type(value) ~= "table" then
print(tostring(value))
return
end
if msg then print(msg) end
if depth == nil then depth = 0 end
if depth > 200 then
print("Error: Depth > 200 in dumpTable()")
print("Error: Depth > 200 in dump()")
return
end
for k, v in pairs(table) do
for k, v in pairs(value) do
if type(v) == "table" then
print(string.rep(" ", depth) .. tostring(k) .. ":")
shared.dumpTable(v, nil, depth + 1)
shared.dump(v, msg, depth + 1)
else
print(string.rep(" ", depth) .. tostring(k) .. ": " .. tostring(v))
end