forked from tc39/ecma262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Job from Promise Resolve Functions
This aligns the behavior of handling thenables with the Promises A+ spec, which says when the resolution value is a thenable, you're supposed to synchronously call `thenable.then(onRes, onRej)` ([Step 2.3.3.3][call-then]). Given the example code: ```javascript new Promise(resolve => { resolve(thenable) }); ``` The current behavior requires 2 ticks for the outer promise to fully resolve. One tick is created tick is created by the Promise Resolving Functions (and is removed in this PR), and one tick is created by the wrapping of the `onRes`/`onRej` callbacks passed to [`Promise.p.then`][then]. This made it noticeably slower to resolve with a thenable then to invoke the thenable's `.then` directly: `thenable.then(onRes, onRej)` only requires a single tick (for the wrapped `onRes`/`onRej`). With this change, we could revert tc39#1250 without slowing down `Await`. Fixes tc39#2770. [call-then]: https://promisesaplus.com/#point-56 [then]: https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-performpromisethen
- Loading branch information
1 parent
656f0cf
commit 4e7ffb3
Showing
1 changed file
with
5 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters