Skip to content

Commit

Permalink
refactor(es_extended/shared): move ESX.DumpTable to the correct module
Browse files Browse the repository at this point in the history
  • Loading branch information
Mycroft-Studios committed Dec 15, 2024
1 parent 7b30c71 commit 4b046be
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
35 changes: 0 additions & 35 deletions [core]/es_extended/shared/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,6 @@ function ESX.GetConfig()
return Config
end

---@param table table
---@param nb? number
---@return string
function ESX.DumpTable(table, nb)
if nb == nil then
nb = 0
end

if type(table) == "table" then
local s = ""
for _ = 1, nb + 1, 1 do
s = s .. " "
end

s = "{\n"
for k, v in pairs(table) do
if type(k) ~= "number" then
k = '"' .. k .. '"'
end
for _ = 1, nb, 1 do
s = s .. " "
end
s = s .. "[" .. k .. "] = " .. ESX.DumpTable(v, nb + 1) .. ",\n"
end

for _ = 1, nb, 1 do
s = s .. " "
end

return s .. "}"
else
return tostring(table)
end
end

---@param value any
---@param numDecimalPlaces? number
---@return number
Expand Down
35 changes: 35 additions & 0 deletions [core]/es_extended/shared/modules/table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,38 @@ function ESX.Table.ToArray(table)
end
return array
end

---@param table table
---@param nb? number
---@return string
function ESX.DumpTable(table, nb)
if nb == nil then
nb = 0
end

if type(table) == "table" then
local s = ""
for _ = 1, nb + 1, 1 do
s = s .. " "
end

s = "{\n"
for k, v in pairs(table) do
if type(k) ~= "number" then
k = '"' .. k .. '"'
end
for _ = 1, nb, 1 do
s = s .. " "
end
s = s .. "[" .. k .. "] = " .. ESX.DumpTable(v, nb + 1) .. ",\n"
end

for _ = 1, nb, 1 do
s = s .. " "
end

return s .. "}"
else
return tostring(table)
end
end

0 comments on commit 4b046be

Please sign in to comment.