Fix possible issue with iteration variable changing

This commit is contained in:
Empathic Qubit 2021-05-07 23:35:10 -04:00
parent 32778cf9fd
commit 2e53f92179
2 changed files with 3 additions and 3 deletions

View file

@ -222,8 +222,8 @@ return function(promise)
local waiters = {}
for i=1,#speciesSlice,1 do
local outputPipe = _M.poppets[i].output
local waiter = util.promiseWrap(function()
local outputPipe = _M.poppets[i].output
local line = outputPipe:read("*l")
print("Started receiving output from child process "..i)

View file

@ -12,9 +12,9 @@ _M.isWin = package.config:sub(1, 1) == '\\'
--- Useful for decoupling code from the original event it was fired in.
---@param next function The function to resolve on the next tick
---@return Promise Promise A promise that returns the value of the next function
function _M.promiseWrap(next)
function _M.promiseWrap(next, value)
local promise = Promise.new()
promise:resolve()
promise:resolve(value)
return promise:next(next)
end