drive-detector
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Drive Detector

A module to get events when drives mount and unmount.

Usage

import DriveDetector from 'drive-detector';
 
const detector = DriveDetector();
 
detector.on('mounted', (drive) => {
  console.log('The drive that was just now mounted:', drive);
});
  
detector.on('unmounted', (drive) => {
  console.log('The drive that was just now unmounted:', drive);
});
  
detector.on('started', (drives) => {
  console.log('Starting detector, currently these drives are mounted:', drives);
});
 
detector.on('error', (err) => {
  // do something with the error
  console.error(err);
});
 
detector.start(2000); // Default: 5000 milliseconds.

The DriveDetector works by a polling mechanism. In the start() method, you can define how often you want it to poll.

Package Sidebar

Install

npm i drive-detector

Weekly Downloads

1

Version

1.2.0

License

MIT

Unpacked Size

8.79 kB

Total Files

14

Last publish

Collaborators

  • wvleeuwen