add dump() to utils

This commit is contained in:
Hersi 2023-11-14 07:35:48 +01:00
parent e876def36f
commit 52cc1beb7d
1 changed files with 14 additions and 0 deletions

View File

@ -79,6 +79,19 @@ local function firstAlphaNum(s)
return ''; return '';
end end
local function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
return { return {
split = split, split = split,
filter = filter, filter = filter,
@ -91,4 +104,5 @@ return {
mix = mix, mix = mix,
modIndex = modIndex, modIndex = modIndex,
firstAlphaNum = firstAlphaNum, firstAlphaNum = firstAlphaNum,
dump = dump
} }