Skip to content

Commit 89497b2

Browse files
committed
Make devicesFound callback and return optional
1 parent 636bcff commit 89497b2

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webusb",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Node.js implementation of the WebUSB Specification",
55
"homepage": "https://github.com/thegecko/webusb",
66
"author": "Rob Moran <[email protected]>",

src/adapter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export class USBAdapter extends EventEmitter implements Adapter {
471471
? bufferSource.buffer.slice(bufferSource.byteOffset, bufferSource.byteOffset + bufferSource.byteLength)
472472
: bufferSource;
473473

474-
return new Buffer(arrayBuffer);
474+
return Buffer.from(arrayBuffer);
475475
}
476476

477477
private getEndpoint(device: Device, direction: USBDirection, endpointNumber: number): Endpoint {

src/interfaces.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface USBOptions {
3333
/**
3434
* A `device found` callback function to allow the user to select a device
3535
*/
36-
devicesFound?: (devices: Array<USBDevice>, selectFn: (device: USBDevice) => void) => USBDevice;
36+
devicesFound?: (devices: Array<USBDevice>, selectFn?: (device: USBDevice) => void) => USBDevice | void;
3737
}
3838

3939
/**

src/usb.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class USB extends EventDispatcher {
4545
public static EVENT_DEVICE_DISCONNECT: string = "disconnect";
4646

4747
private allowedDevices: Array<USBDevice> = [];
48-
private devicesFound: (devices: Array<USBDevice>, selectFn: (device: USBDevice) => void) => USBDevice = null;
48+
private devicesFound: (devices: Array<USBDevice>, selectFn?: (device: USBDevice) => void) => USBDevice | void;
4949

5050
/**
5151
* USB constructor

0 commit comments

Comments
 (0)