Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sudhakar3697/node-detect-usb
Detect USB and get mount points/paths
https://github.com/sudhakar3697/node-detect-usb
mount-points usb usb-detection
Last synced: about 11 hours ago
JSON representation
Detect USB and get mount points/paths
- Host: GitHub
- URL: https://github.com/sudhakar3697/node-detect-usb
- Owner: sudhakar3697
- License: mit
- Created: 2020-04-03T07:21:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-23T02:37:08.000Z (11 months ago)
- Last Synced: 2024-11-01T22:38:42.725Z (17 days ago)
- Topics: mount-points, usb, usb-detection
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/detect-usb
- Size: 7.81 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# detect-usb
Detect USB and get mount points/paths## Usage
```javascript
const usbEvents = require('detect-usb');// To start listening
usbEvents.startListening();// To get list of connected USBs
(async () => {
console.log(await usbEvents.getUSBList());
})();usbEvents.on('insert', (data) => {
console.log(data);
})usbEvents.on('eject', (data) => {
console.log(data);
})// To stop listening
usbEvents.stopListening();
```## Sample Data
```json5
{
event: 'insert',
data:
{
key: '/media/test/sss',
name: 'sss',
devicepath: '/dev/sda',
isAccessible: true
}
}{ event: 'eject', data: { key: '/media/test/sss' } }
```## Note
* Verified on Windows & Linux
* Uses [usb-detection](https://www.npmjs.com/package/usb-detection) & [drivelist](https://www.npmjs.com/package/drivelist)