thegecko / webusb

Node.js implementation of the WebUSB Specification
https://thegecko.github.io/webusb/
MIT License
183 stars 27 forks source link

make device selector async. #64

Closed nodech closed 4 years ago

nodech commented 4 years ago

Note: Unfortunately, this is breaking change.

For terminal UI, or selected device with little bit more complicated logic (that requires async operations) will not be able to use current API.

With this it's possible to build UI or do more advanced selecting.

I also removed second parameter selectFn, because I believe it can be misleading for API consumers. It can be called by the user and still return another device which in turn will resolve promise twice, so instead we don't expose selectFn and devicesFound will just return device or void.

I also added another check for USBDevice for javascript consumers.