Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as usb from "usb";
const device = new usb.Device();
device.timeout = 1;
device.busNumber = 1;
device.deviceAddress = 1;
device.portNumbers = [1, 2, 3];
device.__open();
device.__claimInterface(0);
device.open(true);
device.close();
const xferDevice: usb.Device = device.controlTransfer(1, 1, 1, 1, 1, (error: string, buf: Buffer): usb.Device => new usb.Device());
device.getStringDescriptor(1, (error: string, buf: Buffer) => null);
device.setConfiguration(1, (error: string) => null);
device.reset((error: string) => null);
constructor(...args: any[]) {
let resource: string | null = null;
if (args.length === 1) {
if (typeof args[0] === "string") {
resource = args[0];
} else if (args[0] instanceof usb.Device) {
this.device = args[0];
} else if (typeof args[0] === "object") {
if (args[0].idVendor) {
this.idVendor = args[0].idVendor;
}
if (args[0].idVendor) {
this.idVendor = args[0].idVendor;
}
if (args[0].idProduct) {
this.idProduct = args[0].idProduct;
}
if (args[0].iSerial) {
this.iSerial = args[0].iSerial;
}
if (args[0].device) {
this.device = args[0].device;