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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the getInputData() function #545

Merged

Conversation

aloisklink
Copy link
Member

馃搼 Summary

This is pretty minor, but currently the getInputData() function is:

  • an async() function (inefficient since we don't use async)
  • an arrow function (=>) (not needed)
  • and it returns a very big Promise(), which is considered bad practice, since it doesn't handle errors well, and it does show a good JavaScript Exception stack

I've simplified the function, and replaced some of the manual promise() code with Node.JS's fs.promises API.

馃搹 Design Decisions

Originally, I made these commits a long time ago, but forgot about them!

馃搵 Tasks

Make sure you

  • 馃摉 have read the contribution guidelines
  • 馃捇 have added unit/e2e tests (if appropriate)
    • We already have tests that test this function.
  • 馃敄 targeted master branch

Move things out of the `Promise` callback in `getInputData` that don't
need to be in it.
Document getInputData(), and change it to a proper JavaScript function
instead of a arrow function.
@MindaugasLaganeckas MindaugasLaganeckas merged commit 56b5fae into mermaid-js:master Jun 1, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants