Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise: add .finally() #388

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

wmertens
Copy link

@wmertens wmertens commented Apr 24, 2023

@josdejong
Copy link
Owner

Thanks Wout!

Interesting to see that the finally propagates both the result or error, I wasn't aware of that.

Two feedbacks:

  • I'm wondering if there is need to document this method. I think not, since it's so standard. What do you think?
  • Can you write unit tests for this method?

@joshLong145
Copy link

@josdejong @wmertens
This will be a useful addition until there can be a migration to the native Promise library. I have added some tests in a new branch to confirm matching functionality with the native finally implementation.

https://github.com/joshLong145/workerpool/tree/feat/add-promise-finally

@wmertens
Copy link
Author

@joshLong145 I added your commit to this branch

@josdejong
Copy link
Owner

Thanks for the update Wout, it has been a while 😅 .

Two remarks:

  1. Can you describe the new .finally() method in the README.md? There is a list with all methods there that can be extended.
  2. I think the unit tests need to be extended a bit: when I remove the .then and .catch from the two tests, the test still succeeds. So, I think the test should check whether the .then and .catch have been trigered before calling done. It is valuable at least to verify the order in which the .then, .catch, and .finally are triggered so these two tests make sense to me.
  3. Similarly, the finally method neatly propagates either the success or failure, but this is not yet captured in a unit test. Can you add two unit tests for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Promise.prototype.finally
3 participants