1.0.0 • Published 1 year ago

@nico-martin/webusb-controller v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

WebUSBController Class

A JavaScript class that abstracts the WebUSB API and concentrates it on a handful of methods:

Install

npm i @nico-martin/webusb-controller

About

import WebUSBController from '@nico-martin/webusb-controller';

const Controller = new WebUSBController();

// Connect to a device, accepts USBDeviceRequestOptions as a parameter
Controller.connect({ filters: [{ vendorId: 0x2e8a }] });

// Send a DataView to the connected device
Controller.send(new Uint8Array([0, 255]));

// listener that accepts a callback function that runs whenever new data (DataView) is sent
Controller.onReceive((data) => console.log('received', data));

// listener that accepts a callback function that runs whenever a device is connected or disconnected
Controller.onDeviceConnect((device) =>
  console.log(device ? 'connect' : 'disconnect')
);
1.0.0

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago