feat(utils): add has_value function

This commit is contained in:
2024-04-14 16:04:17 +02:00
parent dc0c406308
commit a7a4d4a5c5
+15
View File
@@ -132,4 +132,19 @@ function M.update_table(table, values)
end end
end end
--- Check if a table contains a value
---@generic T
---@param table table<any, T> Table to inspect
---@param value T Value to check
---@return boolean
function M.has_value(table, value)
for _, v in ipairs(table) do
if v == value then
return true
end
end
return false
end
return M return M