mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-24 15:50:01 +00:00
remove promise check
This commit is contained in:
parent
1ac7d3cae9
commit
ce6c12f177
1 changed files with 4 additions and 8 deletions
|
@ -443,15 +443,11 @@ function Promise.fold(list, callback, initialValue)
|
|||
assert(type(list) == "table", "Bad argument #1 to Promise.fold: must be a table")
|
||||
assert(type(callback) == "function", "Bad argument #2 to Promise.fold: must be a function")
|
||||
|
||||
local accumulator = initialValue
|
||||
local accumulator = Promise.resolve(initialValue)
|
||||
return Promise.each(list, function(resolvedElement, i)
|
||||
if Promise.is(accumulator) then
|
||||
accumulator = accumulator:andThen(function(previousValueResolved)
|
||||
return callback(previousValueResolved, resolvedElement, i)
|
||||
end)
|
||||
else
|
||||
accumulator = callback(accumulator, resolvedElement, i)
|
||||
end
|
||||
end):andThenReturn(accumulator)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue