From 17ebeb7dc998be9ab7dd89aff046141a0de07acf Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 3 Nov 2023 15:10:42 +0100 Subject: [PATCH] api: add function to determine empty tables --- api/api.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/api.lua b/api/api.lua index 48165ecc..42dd90ca 100644 --- a/api/api.lua +++ b/api/api.lua @@ -21,6 +21,18 @@ function pfUI.api.strsplit(delimiter, subject) return unpack(fields) end +-- [ isempty ] +-- Returns true if a table is empty or not existing, otherwise false. +-- 'tbl' [table] the table that shall be checked +-- return: [boolean] result of the check. +function pfUI.api.isempty(tbl) + if not tbl then return true end + for k, v in pairs(tbl) do + return false + end + return true +end + -- [ checkversion ] -- Compares a given version (major,minor,fix) and compares it to the current -- 'chkmajor' [number] the major number to check