promises-aplus / promises-spec

An open standard for sound, interoperable JavaScript promises—by implementers, for implementers.
https://promisesaplus.com/
Creative Commons Zero v1.0 Universal
1.84k stars 171 forks source link

Confused about the point of 2.3.2 #297

Open jugheadjones10 opened 2 years ago

jugheadjones10 commented 2 years ago

I’m confused about why 2.3.2 doesn’t mention anything about recursively unwrapping thenables like in 2.3.3.3. It just says that “if/when x is fulfilled, fulfill promise with the same value”. But what if that value is a promise? Aren’t we not supposed to fulfill a promise with another promise?

Also, is there a reason we use the function names resolvePromise and rejectPromise in 2.3.3.3 instead of onFulfilled and onRejected like earlier in the documentation?

One hypothesis I have is that 2.3.3.3 is dealing with situations where thenables are “untrustable”, meaning the value that resolvePromise is called with may very well be a thenable, hence necessitating the recursive unwrapping. That would make 2.3.2 make sense, because if our promise is “trustable” then it wouldn’t fulfill with a promise anyway, allowing us to omit recursive unwrapping in 2.3.2. Does this in any way describe what is going on?

Thanks.