Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions lua/wikis/commons/Class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,30 +118,9 @@ end
---@param options table?
---@return F
function Class._wrapFunction(f, options)
options = options or {}
local alwaysRewriteArgs = options.trim
or options.removeBlanks
or options.valueFunc ~= nil

return function(...)
-- We cannot call getArgs with a spread operator when these are just lua
-- args, so we need to wrap it
local input = {...}

local frame = input[1]
local shouldRewriteArgs = alwaysRewriteArgs
or (
#input == 1
and type(frame) == 'table'
and type(frame.args) == 'table'
)

if shouldRewriteArgs then
local args = Arguments.getArgs(frame, options)
return f(args)
else
return f(...)
end
return function(frameOrArgs)
local args = Arguments.getArgs(frameOrArgs, options or {})
return f(args)
end
end

Expand Down
Loading