From 0390af3d420abce1e262c1ab3e7f9c05995933c8 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Fri, 28 Feb 2025 09:39:21 +0100 Subject: [PATCH] Add table.trim --- cf-lib/util/table.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cf-lib/util/table.lua b/cf-lib/util/table.lua index 3f829a0..0e8f32b 100644 --- a/cf-lib/util/table.lua +++ b/cf-lib/util/table.lua @@ -83,4 +83,13 @@ function table.concat(table1, table2) table.insert(result, v) end return result +end + +--- Trims nil values from a table. +--- @param target table The table to trim +--- @return table The trimmed table +function table.trim(target) + return table.filter(target, function(v) + return v ~= nil + end) end \ No newline at end of file