Skip to content

Commit 1cf4596

Browse files
committed
refactor: change assumption in the wait function
1 parent bad4edb commit 1cf4596

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lua/async.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ end
140140
--- @tparam function func callback style function to execute
141141
--- @tparam any ... Arguments for func
142142
function M.wait(...)
143-
if type(select(1, ...)) == 'number' then
143+
if type(...) == 'number' then
144144
return wait(...)
145+
else
146+
-- Assume argc is equal to the number of passed arguments + 1 for callback.
147+
local nargs = select('#', ...)
148+
return wait(nargs + 1, ...)
145149
end
146-
147-
-- Asume argc is equal to the number of passed arguments.
148-
return wait(select('#', ...) - 1, ...)
149150
end
150151

151152
--- Use this to create a function which executes in an async context but

0 commit comments

Comments
 (0)