aboutsummaryrefslogtreecommitdiff
path: root/utils.lua
blob: 7580387c07d5914c1b9f61a844749bb7e56bb76e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local utils = {}

function utils.dumpt(tt, result)
    local r = result or {}
    if type(tt) == 'table' then
        table.insert(r, '{')
        for k, v in pairs(tt) do
            table.insert(r, '[')
            utils.dumpt(k, r)
            table.insert(r, ']=')
            utils.dumpt(v, r)
            table.insert(r, ',')
        end
        table.insert(r, '}')
    elseif type(tt) == 'string' then
        table.insert(r, string.format('%q', tt))
    else
        table.insert(r, tostring(tt))
    end
    return r
end

function utils.dump(tt)
    return table.concat(utils.dumpt(tt))
end

return utils