feat(inject): util method to get upvalue

This commit is contained in:
Folke Lemaitre 2023-10-12 09:42:48 +02:00
parent 85215f396b
commit 14f3f036e9

View file

@ -17,4 +17,18 @@ function M.args(fn, wrapper)
end
end
function M.get_upvalue(func, name)
local i = 1
while true do
local n, v = debug.getupvalue(func, i)
if not n then
break
end
if n == name then
return v
end
i = i + 1
end
end
return M