Promise finally
Raul-Sebastian Mihăilă
raul.mihaila at gmail.com
Sat Feb 24 09:22:16 UTC 2018
Trying better formatting for esdiscuss.org.
```
CreateResolvingFunctions(promise, finallySourcePromise)
update step 3: Let resolve be CreateBuiltinFunction(stepsResolve, «
[[Promise]], [[AlreadyResolved]], [[FinallySourcePromise]] »).
insert new step 6: Set resolve.[[FinallySourcePromise]] to
finallySourcePromise.
GetCapabilitiesExecutor Functions
A GetCapabilitiesExecutor function is an anonymous built-in function that
has a [[Capability]] and a [[FinallySourcePromise]] internal slots.
NewPromiseCapability(C, finallySourcePromise = undefined)
update step 5: Let executor be CreateBuiltinFunction(steps, «
[[Capability]], [[FinallySourcePromise]] »).
insert new step 7: Set executor.[[FinallySourcePromise]] to
finallySourcePromise.
Promise ( executor )
insert step 8: Let finallySourcePromise be undefined.
insert setp 9: If executor has a internal slot [[FinallySourcePromise]]
Let finallySourcePromise be executor.[[FinallySourcePromise]]
update step 8 (which now becomes step 10): Let resolvingFunctions be
CreateResolvingFunctions(promise, finallySourcePromise).
PromiseResolveThenableJob(promiseToResolve, thenable, then,
finallySourcePromise)
The job PromiseResolveThenableJob with parameters promiseToResolve,
thenable, then and finallySourcePromise performs the following steps:
update step 1: Let resolvingFunctions be
CreateResolvingFunctions(promiseToResolve,
finallySourcePromise).
Promise.prototype.finally(onFinally)
Let promise be the this value.
If IsPromise(promise) is false, throw a TypeError exception.
Let C be ? SpeciesConstructor(promise, %Promise%).
Let resultCapability be ? NewPromiseCapability(C, promise).
Return PerformPromiseThen(promise, onFinally, onFinally,
resultCapability).
Promise Resolve Functions
update step 7: If Type(resolution) is not Object, then
Let finallySourcePromise be F.[[FinallySourcePromise]]
If finallySourcePromise is undefined
return FulfillPromise(promise, resolution).
Else
If finallySourcePromise.[[PromiseState]] is "rejected"
return RejectPromise(promise, finallySourcePromise.[[
PromiseResult]])
Else
return FulfillPromise(promise, finallySourcePromise.[[
PromiseResult]])
update step 12: Perform EnqueueJob("PromiseJobs",
PromiseResolveThenableJob, « promise, resolution, thenAction,
F.[[FinallySourcePromise]] »).
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180224/5dcabf75/attachment-0001.html>
More information about the es-discuss
mailing list