diff --git a/lua/lazy/util.lua b/lua/lazy/util.lua index 2356f63..5739feb 100644 --- a/lua/lazy/util.lua +++ b/lua/lazy/util.lua @@ -134,4 +134,16 @@ function M.dump(value) return table.concat(result, "") end +---@generic V +---@param t table +---@param fn fun(key:string, value:V) +function M.foreach(t, fn) + ---@type string[] + local keys = vim.tbl_keys(t) + table.sort(keys) + for _, key in ipairs(keys) do + fn(key, t[key]) + end +end + return M