mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-25 18:28:50 +02:00
feat(inject): util method to get upvalue
This commit is contained in:
parent
85215f396b
commit
14f3f036e9
1 changed files with 14 additions and 0 deletions
|
@ -17,4 +17,18 @@ function M.args(fn, wrapper)
|
||||||
end
|
end
|
||||||
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
|
return M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue