diff --git a/lua/core/util.lua b/lua/core/util.lua index 06f687b849c1d2fe8a5b0184fe3e2554bc81d050..3c79afa04406b20269d86cb19a13ae09de8a3320 100644 --- a/lua/core/util.lua +++ b/lua/core/util.lua @@ -258,6 +258,17 @@ function table.forEach(self, func) end end +---@generic T +---@param self T[] +---@param func fun(element: T, index: integer, array: T[]): boolean? +---@return boolean +function table.some(self, func) + for i, v in ipairs(self) do + if func(v, i, self) then return true end + end + return false +end + ---@generic T ---@param self T[] ---@param func fun(element: T, index: integer, array: T[]): boolean?