From 8c41bce1282c8c1542bfc8446f6454230dbc2111 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 6 Jun 2021 19:18:53 +0200 Subject: [PATCH] feat: add new table functions --- sonic-radiance.love/birb/utils/table.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sonic-radiance.love/birb/utils/table.lua b/sonic-radiance.love/birb/utils/table.lua index 3e859cb..a65e109 100644 --- a/sonic-radiance.love/birb/utils/table.lua +++ b/sonic-radiance.love/birb/utils/table.lua @@ -52,10 +52,26 @@ function Table.toString(table) return string .. "}" end +function Table.clone(table1) + local returnTable = {} + for key, value in pairs(table1) do + returnTable[key] = value + end + return returnTable +end + function Table.mergeList(table1, table2) for i, value in ipairs(table2) do table.insert(table1, value) end + return table1 +end + +function Table.merge(table1, table2) + for key, value in pairs(table2) do + table1[key] = value + end + return table1 end function Table.reduce(list, fn)