Open jcsahnwaldt opened 7 years ago
In general, if a spec does not tell you to do something, then indeed, you do not do anything. That is implicit, and doesn't need to be spelled out.
Let's assume the original promise (which we should denote by the object promise
) will eventually settle (that is, get resolved or rejected).
Then if you have set up the promise like promise.then(onResolve, onReject)
, then either of onResolve
or onReject
is called depending on the state of promise
(if it's not a function, then the new promise will be equivalent to the old one), with the sole argument being the value or reason of the original promise. The resulting function may either return or throw, and returning will resolve the new promise, while throwing will reject the new promise.
Returning without any value is equivalent to returning void 0
(AKA undefined
); in this case the new promise is fulfilled with the value undefined
.
In The Promise Resolution Procedure step 3.iii, cases a through d are considered:
But what if
then
neither throws an exception nor calls one of its arguments? It may simply do nothing and return. Probably a rare case, but it looks like an omission to me. Or am I missing something?