remove table_tostring (#1036)
This commit is contained in:
committed by
GitHub
parent
38cc6305b4
commit
9b03ab40e8
@@ -245,40 +245,4 @@ function M.table_create_missing(tbl, sub)
|
||||
return t
|
||||
end
|
||||
|
||||
-- Serialise a table as a string
|
||||
-- @param val table to serialise
|
||||
-- @param name optional
|
||||
-- @param skipnewlines optional
|
||||
-- @param spaces to indent, for internal use
|
||||
function M.table_tostring(val, name, skipnewlines, depth)
|
||||
skipnewlines = skipnewlines or false
|
||||
depth = depth or 0
|
||||
|
||||
local tmp = string.rep(" ", depth)
|
||||
|
||||
if name then
|
||||
tmp = tmp .. name .. " = "
|
||||
end
|
||||
|
||||
if type(val) == "table" then
|
||||
tmp = tmp .. "{" .. (not skipnewlines and "\n" or "")
|
||||
|
||||
for k, v in pairs(val) do
|
||||
tmp = tmp .. M.table_tostring(v, k, skipnewlines, depth + 1) .. "," .. (not skipnewlines and "\n" or "")
|
||||
end
|
||||
|
||||
tmp = tmp .. string.rep(" ", depth) .. "}"
|
||||
elseif type(val) == "number" then
|
||||
tmp = tmp .. tostring(val)
|
||||
elseif type(val) == "string" then
|
||||
tmp = tmp .. string.format("%q", val)
|
||||
elseif type(val) == "boolean" then
|
||||
tmp = tmp .. tostring(val)
|
||||
else
|
||||
tmp = tmp .. "\"[" .. type(val) .. "]\""
|
||||
end
|
||||
|
||||
return tmp
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user