Skip to content

Commit

Permalink
fix(async): simplify setfenv function
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhwang91 committed Feb 27, 2024
1 parent e8d3271 commit 81a9878
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions lua/async.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,10 @@ local function hasPacked(o)
return type(o) == 'table' and o._id == packedId
end

local function apcall(f, ...)
local function result(ok, ...)
if ok then
return true, ...
end
local err = select(1, ...)
return false, err
end

return result(compat.pcall(f, ...))
end

local function injectENV(fn)
compat.setfenv(fn, setmetatable({
await = Async.wait,
pcall = apcall,
pcall = compat.pcall,
xpcall = compat.xpcall
}, {
__index = compat.getfenv(fn)
Expand Down

0 comments on commit 81a9878

Please sign in to comment.