diff --git a/lua/qvim/log/log.lua b/lua/qvim/log/log.lua index d152363..078e4ff 100644 --- a/lua/qvim/log/log.lua +++ b/lua/qvim/log/log.lua @@ -1,4 +1,3 @@ -local fn_t = require("qvim.utils.fn_t") local utils = require("qvim.utils") ---@class StructlogImpl @@ -25,6 +24,18 @@ StructlogImpl.levels = { } vim.tbl_add_reverse_lookup(StructlogImpl.levels) +---@param t any +---@param predicate fun(entry: any):boolean +---@return boolean +local function any(t, predicate) + for _, entry in pairs(t) do + if predicate(entry) then + return true + end + end + return false +end + ---Setup Structlog with its channels and mutates the log table to index the log functions ---@param self StructlogImpl ---@param channels table @@ -51,7 +62,7 @@ function StructlogImpl:setup(channels, log) ---@return function __index = function(tbl, key) if - fn_t.any(vim.tbl_keys(channels), function(entry) + any(vim.tbl_keys(channels), function(entry) return key == entry end) then diff --git a/lua/qvim/utils/fn_t.lua b/lua/qvim/utils/fn_t.lua index 47b1513..ecd9bff 100644 --- a/lua/qvim/utils/fn_t.lua +++ b/lua/qvim/utils/fn_t.lua @@ -58,7 +58,7 @@ end ---Checks if any entry in a table satisfies a predicate ---@param t any ----@param predicate any +---@param predicate fun(entry: any):boolean ---@return boolean function Table.any(t, predicate) for _, entry in pairs(t) do