From 36dba7614eef7b2d845931db58eabeaef4b950b9 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Sun, 6 Apr 2025 16:43:21 +0200 Subject: [PATCH] Add table.count --- cf-lib/util/table.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cf-lib/util/table.lua b/cf-lib/util/table.lua index e44b559..865d683 100644 --- a/cf-lib/util/table.lua +++ b/cf-lib/util/table.lua @@ -92,4 +92,15 @@ function table.trim(target) return table.filter(target, function(v) return v ~= nil end) +end + +--- Counts the entries of given table. +--- @param target table Table to count +--- @return number Amount of entries +function table.count(target) + local count = 0 + for _ in pairs(target) do + count = count + 1 + end + return count end \ No newline at end of file