npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

usb-hotplug

v0.1.6

Published

Cross-platform USB hotplug event listener — native Node.js module powered by Rust and nusb. Zero dependencies, built-in TypeScript types, automatic event debouncing.

Readme

usb-hotplug

Cross-platform USB hotplug listener for Node.js. Native Rust core via nusb -- no libusb, no C dependencies, built-in TypeScript types.

Supports macOS, Linux, and Windows.

Features

  • Real-time USB connect/disconnect events
  • Built-in debouncing -- OS-level re-enumeration noise (e.g. iPhones) is coalesced into a single event
  • List all currently connected USB devices
  • Zero JS dependencies -- single native binary
  • Full TypeScript support out of the box

Install

npm install usb-hotplug

Quick start

import { watchDevices, stopWatching, listDevices } from "usb-hotplug"

// List devices currently connected
const devices = listDevices()
console.log(devices)

// Watch for connect / disconnect
watchDevices((err, event) => {
  if (err) throw err
  console.log(event.eventType, event.serialNumber)
  if (event.device) console.log(event.device)
})

// Stop when done
process.on("SIGINT", () => {
  stopWatching()
  process.exit(0)
})

API

listDevices(): UsbDevice[]

Returns all currently connected USB devices.

watchDevices(callback, debounceMs?): void

Starts listening for USB hotplug events. Only one watcher can be active at a time.

| Parameter | Type | Default | Description | |---|---|---|---| | callback | (err, event) => void | -- | Called for each event | | debounceMs | number | 500 | Debounce window in ms |

The debounce window coalesces rapid event bursts caused by OS-level USB re-enumeration (a device appearing to disconnect and reconnect within milliseconds). With the default 500 ms window, you receive exactly one Connected event per physical plug-in.

stopWatching(): void

Stops the active watcher. The background thread exits after the current event or on process exit.

Types

interface UsbEvent {
  eventType: "Connected" | "Disconnected"
  deviceId: string
  serialNumber?: string
  device?: UsbDevice       // present on Connected, absent on Disconnected
}

interface UsbDevice {
  vendorId: number
  productId: number
  manufacturer?: string
  product?: string
  serialNumber?: string
  deviceClass: number
  deviceSubclass: number
  deviceProtocol: number
  busId: string
  deviceAddress: number
}

Platform support

| Platform | Architecture | Status | |---|---|---| | macOS | arm64, x86_64 | Supported | | Linux | x86_64 | Supported | | Windows | x86_64 | Supported |

Building from source

Requires Rust and Node.js >= 16.

npm install
npm run build

License

MIT