Socket
Socket
Sign inDemoInstall

usb

Package Overview
Dependencies
Maintainers
3
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

usb - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

libusb/.private/ci-container-build.sh

7

CHANGELOG.md
# Changelog
## [2.3.0] - 2022-04-11
### Changed
- Changed libusb dependency to upstream v1.0.26 - [`505`](https://github.com/node-usb/node-usb/pull/505) ([Rob Moran](https://github.com/thegecko))
- Cleaned up Windows device polling method - [`496`](https://github.com/node-usb/node-usb/pull/496) ([Alba Mendez](https://github.com/mildsunrise))
## [2.2.0] - 2022-03-25

@@ -4,0 +11,0 @@

23

dist/usb/index.js

@@ -29,3 +29,3 @@ "use strict";

var pollingHotplug = false;
var pollDevices = [];
var pollDevices = new Set();
var pollHotplug = function (start) {

@@ -40,10 +40,5 @@ var e_1, _a, e_2, _b;

}
var devices = usb.getDeviceList();
// Collect current devices
var devices = new Set(usb.getDeviceList());
if (!start) {
var _loop_1 = function (device) {
var found = pollDevices.find(function (item) { return item.deviceAddress === device.deviceAddress; });
if (!found) {
usb.emit('attach', device);
}
};
try {

@@ -53,3 +48,4 @@ // Find attached devices

var device = devices_1_1.value;
_loop_1(device);
if (!pollDevices.has(device))
usb.emit('attach', device);
}

@@ -64,8 +60,2 @@ }

}
var _loop_2 = function (device) {
var found = devices.find(function (item) { return item.deviceAddress === device.deviceAddress; });
if (!found) {
usb.emit('detach', device);
}
};
try {

@@ -75,3 +65,4 @@ // Find detached devices

var device = pollDevices_1_1.value;
_loop_2(device);
if (!devices.has(device))
usb.emit('detach', device);
}

@@ -78,0 +69,0 @@ }

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "2.2.0",
"version": "2.3.0",
"main": "dist/index.js",

@@ -8,0 +8,0 @@ "engines": {

@@ -15,4 +15,18 @@ # USB Library for Node.JS

On Windows, use [Zadig](http://zadig.akeo.ie/) to install the WinUSB driver for your USB device. Otherwise you will get `LIBUSB_ERROR_NOT_SUPPORTED` when attempting to open devices.
## Windows
On Windows, if you get `LIBUSB_ERROR_NOT_SUPPORTED` when attempting to open your device, it's possible your device doesn't have a WinUSB driver for libusb to use.
You can install one using [Zadig](http://zadig.akeo.ie/) or another approach is to use the [UsbDK Backend](https://github.com/daynix/UsbDk) of libusb by immediately calling `usb.useUsbDkBackend()`.
Note that you cannot use multiple drivers on Windows as they get exclusive access to the device. So if you want to switch between drivers (e.g. using a printer with this software or the system), you will need to uninstall/install drivers as required.
## Linux
On Linux, you'll need libudev to build libusb if a prebuild is not available. On Ubuntu/Debian:
```bash
sudo apt-get install build-essential libudev-dev
```
# Installation

@@ -34,3 +48,3 @@

__Note:__ the library is now written in `TypeScript`, so a separate types file is not longer required to be installed.
__Note:__ the library is now written in `TypeScript`, so a separate types file is not longer required to be installed (e.g. don't install `@types/usb`).

@@ -37,0 +51,0 @@ # License

@@ -48,3 +48,3 @@ import { EventEmitter } from 'events';

let pollingHotplug = false;
let pollDevices: usb.Device[] = [];
let pollDevices = new Set<usb.Device>();

@@ -58,3 +58,4 @@ const pollHotplug = (start = false) => {

const devices = usb.getDeviceList();
// Collect current devices
const devices = new Set(usb.getDeviceList());

@@ -64,6 +65,4 @@ if (!start) {

for (const device of devices) {
const found = pollDevices.find(item => item.deviceAddress === device.deviceAddress);
if (!found) {
if (!pollDevices.has(device))
usb.emit('attach', device);
}
}

@@ -73,6 +72,4 @@

for (const device of pollDevices) {
const found = devices.find(item => item.deviceAddress === device.deviceAddress);
if (!found) {
if (!devices.has(device))
usb.emit('detach', device);
}
}

@@ -79,0 +76,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc