mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-24 17:58:51 +02:00
feat(inject): util method to get upvalue
This commit is contained in:
parent
f98c4a26b3
commit
204be37843
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue