From db67607201a55d7a2d578c6c7661c8e6770f5b2f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 6 Sep 2025 13:49:19 -0400 Subject: docs: manpage, keycodes, json --- runtime/lua/vim/shared.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'runtime/lua/vim/shared.lua') diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 014b64c18b..8c55081050 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -244,20 +244,21 @@ function vim.tbl_values(t) return values end ---- Apply a function to all values of a table. +--- Applies function `fn` to all values of table `t`, in `pairs()` iteration order (which is not +--- guaranteed to be stable, even when the data doesn't change). --- ---@generic T ----@param func fun(value: T): any Function +---@param fn fun(value: T): any Function ---@param t table Table ---@return table : Table of transformed values -function vim.tbl_map(func, t) - vim.validate('func', func, 'callable') +function vim.tbl_map(fn, t) + vim.validate('fn', fn, 'callable') vim.validate('t', t, 'table') --- @cast t table local rettab = {} --- @type table for k, v in pairs(t) do - rettab[k] = func(v) + rettab[k] = fn(v) end return rettab end @@ -265,17 +266,17 @@ end --- Filter a table using a predicate function --- ---@generic T ----@param func fun(value: T): boolean (function) Function +---@param fn fun(value: T): boolean (function) Function ---@param t table (table) Table ---@return T[] : Table of filtered values -function vim.tbl_filter(func, t) - vim.validate('func', func, 'callable') +function vim.tbl_filter(fn, t) + vim.validate('fn', fn, 'callable') vim.validate('t', t, 'table') --- @cast t table local rettab = {} --- @type table for _, entry in pairs(t) do - if func(entry) then + if fn(entry) then rettab[#rettab + 1] = entry end end -- cgit