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

Use async/await #54

Open
dsanders11 opened this issue Jul 3, 2019 · 1 comment
Open

Use async/await #54

dsanders11 opened this issue Jul 3, 2019 · 1 comment

Comments

@dsanders11
Copy link
Contributor

Not going to open a PR for this because I haven't tested it beyond compilation, and not sure it's something you'll want.

Switching the code to using async/await instead of manually creating promises can simplify some of the code, reduces indentation, and shaves 90 lines off the source.

See 5902723 for a commit that switches most code over to this pattern.

In particular, I think devicetoUSBDevice simplifies nicely, as does openDevice. It also makes the code from #39 more robust, as Promise.all will short-circuit if one of the promises rejects, moving on to closing the adapter while the other promises are still unresolved, which might cause an error.

Some food for thought.

@thegecko
Copy link
Owner

thegecko commented Jul 3, 2019

Aync/await in typescript created bulky code when this library was initially written, so it was avoided.
However I'm keen to switch to this method of doing things in a lot of my libraries. The problem is time and balancing potential bug introductions with new features :)

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

No branches or pull requests

2 participants