| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Review requested:
|
Sorry, something went wrong.
There was a problem hiding this comment.
I'm not sure this is an improvement? The behavior is the same?
Sorry, something went wrong.
|
Yes the behavior is the same. Another way would be to change the name of the function isPromise -> isThenable. |
Sorry, something went wrong.
|
Actually the current implementation (and the one in this PR) is wrong if someone passes a thenable where then is a getter that throws the second time then is accessed. It's not a big bug but promise test suites check for it. The correct implementation would be to do it in "two steps":
See here for an example |
Sorry, something went wrong.
The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once.
|
I've implemented the solution suggested by @benjamingr, PTAL. |
Sorry, something went wrong.
There was a problem hiding this comment.
Please consider adding a test.
If you prefer not to - I'll add one sometime after this lands :]
Sorry, something went wrong.
|
Test added! It does fail on master and not with this PR, PTAL. @ronag Have your concerns been addressed? |
Sorry, something went wrong.
|
@ronag are you still blocking this or can your objection be dismissed? |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once. PR-URL: #35925 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once. PR-URL: #35925 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once. PR-URL: #35925 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
| Back | FazBrowse Home | New Git URL |
The function was not checking if the parameter was actually a Promise
instance, but if it has a then method. Removing the utility function
in favor of a clearer typeof check, handling the case when the
thenable throws if then method is accessed more than once.
The difference between a thenable and a Promise may be important when using third party library (the parameter is provided by the user) and/or when Promise.prototype.then value is changed from userland.
Checklist