What is check-disk-space?
The check-disk-space npm package is used to check the disk space available on a specified drive in a Node.js application. It provides a simple and efficient way to retrieve disk space information, such as free space and total space, which can be crucial for applications that manage or monitor system resources.
What are check-disk-space's main functionalities?
Check Disk Space
This feature allows you to check the disk space of a specified drive. It provides information about the total space and the free space available on the drive. The function returns a promise that resolves with an object containing the disk space details.
const checkDiskSpace = require('check-disk-space').default;
checkDiskSpace('/path/to/directory').then((diskSpace) => {
console.log(diskSpace)
// Output will include:
// diskSpace.free: the available space on the disk
// diskSpace.size: the total size of the disk
});
Other packages similar to check-disk-space
diskusage
The 'diskusage' package provides similar functionality to check-disk-space, offering methods to get the total and free disk space. It differs slightly in its API and the way it handles system calls, potentially affecting performance and compatibility with different Node.js versions.
node-disk-info
node-disk-info is another alternative that fetches disk information. Unlike check-disk-space, it provides more detailed information about each mounted disk drive, including used space, which can be useful for more detailed system analysis and monitoring.
Check disk space
Introduction
Light multi-platform disk space checker without third party for Node.js.
- Works on Linux, macOS and Windows
- Take care of mounting points on unix-like systems
- No dependencies
- TypeScript support
Install
npm install check-disk-space
Usage
import checkDiskSpace from 'check-disk-space'
const checkDiskSpace = require('check-disk-space').default
checkDiskSpace('C:/blabla/bla').then((diskSpace) => {
console.log(diskSpace)
})
checkDiskSpace('/mnt/mygames').then((diskSpace) => {
console.log(diskSpace)
})