2024-01-25 03:39:44 +01:00

19 lines
401 B
Lua

--- Utility functions.
-- @module advtrains_doc_integration.utils
-- @alias M
local M = {}
--- Create a table by applying a function to each element.
-- @tparam table tbl The table to map from.
-- @tparam function func The function to apply.
-- @treturn table The resulting table.
function M.map(tbl, func)
local t = {}
for k, v in pairs(tbl or {}) do
t[k] = func(v)
end
return t
end
return M