feat(inject): util method to get upvalue

This commit is contained in:
Folke Lemaitre 2023-10-12 09:42:48 +02:00
parent f98c4a26b3
commit 204be37843
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

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