mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-24 15:50:01 +00:00
parent
05c603dd1e
commit
e192db7946
2 changed files with 11 additions and 2 deletions
|
@ -626,7 +626,9 @@ function Promise.fold(list, reducer, initialValue)
|
|||
accumulator = accumulator:andThen(function(previousValueResolved)
|
||||
return reducer(previousValueResolved, resolvedElement, i)
|
||||
end)
|
||||
end):andThenReturn(accumulator)
|
||||
end):andThen(function()
|
||||
return accumulator
|
||||
end)
|
||||
end
|
||||
|
||||
--[=[
|
||||
|
|
|
@ -1043,9 +1043,16 @@ return function()
|
|||
end)
|
||||
|
||||
it("should accept promises in the list", function()
|
||||
local sum = Promise.fold({ Promise.resolve(1), 2, 3 }, function(sum, element)
|
||||
local resolve
|
||||
|
||||
local sum = Promise.fold({ Promise.new(function(r)
|
||||
resolve = r
|
||||
end), 2, 3 }, function(sum, element)
|
||||
return sum + element
|
||||
end, 0)
|
||||
|
||||
resolve(1)
|
||||
|
||||
expect(Promise.is(sum)).to.equal(true)
|
||||
expect(sum:getStatus()).to.equal(Promise.Status.Resolved)
|
||||
expect(sum:expect()).to.equal(6)
|
||||
|
|
Loading…
Reference in a new issue