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 code readability #1

Open
samsch opened this issue Oct 4, 2019 · 7 comments
Open

Promise code readability #1

samsch opened this issue Oct 4, 2019 · 7 comments

Comments

@samsch
Copy link
Owner

samsch commented Oct 4, 2019

Which of these can you read and understand the quickest and easiest?

0 Simple Promise

1 Promise.try() flow

2 Promise.try() common formatting

3 Await try..catch

4 Await with errify function

errify function is shown for clarity of function, but would be an imported utility in "real" code.

@samsch
Copy link
Owner Author

samsch commented Oct 4, 2019

0 Simple Promise

@samsch
Copy link
Owner Author

samsch commented Oct 4, 2019

1 Promise.try() flow

@samsch
Copy link
Owner Author

samsch commented Oct 4, 2019

2 Promise.try() common formatting

@samsch
Copy link
Owner Author

samsch commented Oct 4, 2019

3 Await try..catch

@samsch
Copy link
Owner Author

samsch commented Oct 4, 2019

4 Await with errify function

@samsch
Copy link
Owner Author

samsch commented Oct 4, 2019

Some notes:

  • These don't all have identical behavior. Some of them will catch errors from res.sendStatus(200), others won't.

@samsch
Copy link
Owner Author

samsch commented Oct 4, 2019

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

No branches or pull requests

1 participant