feat(inject): util method to get upvalue
This commit is contained in:
1 file changed
+14
@@ -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
|
||||
Reference in new issue
Block a user