Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@sindresorhus/df
Advanced tools
@sindresorhus/df is an npm package that provides a simple way to get free disk space information for all mounted filesystems on a Unix-like operating system. It is a Node.js wrapper around the Unix `df` command.
Get disk space information
This feature allows you to retrieve information about the disk space of all mounted filesystems. The code sample demonstrates how to use the package to get disk space information and log it to the console.
const df = require('@sindresorhus/df');
(async () => {
const diskSpace = await df();
console.log(diskSpace);
})();
The 'diskusage' package provides similar functionality by allowing you to get disk usage information for a specific path. Unlike @sindresorhus/df, which retrieves information for all mounted filesystems, 'diskusage' focuses on a single path.
The 'check-disk-space' package is another alternative that provides disk space information for a specific path. It is cross-platform and works on both Unix-like systems and Windows, whereas @sindresorhus/df is Unix-specific.
The 'node-disk-info' package offers comprehensive disk information, including filesystem type, mount point, and usage statistics. It supports multiple platforms, making it more versatile compared to @sindresorhus/df, which is Unix-specific.
Get free disk space info from
df -kP
Works on any Unix based system like macOS and Linux.
Created because all the other df
wrappers are terrible. This one uses simple and explicit parsing. Uses execFile
rather than exec
. Ensures better platform portability by using the -P
flag. Returns sizes in bytes instead of kilobytes and the capacity as a float.
$ npm install --save @sindresorhus/df
const df = require('@sindresorhus/df');
df().then(list => {
console.log(list);
/*
[{
filesystem: '/dev/disk1',
size: 499046809600,
used: 443222245376,
available: 55562420224,
capacity: 0.89,
mountpoint: '/'
}, ...]
*/
});
df.fs('/dev/disk1').then(data => {
console.log(data);
/*
{
filesystem: '/dev/disk1',
...
}
*/
});
df.file(__dirname).then(data => {
console.log(data);
/*
{
filesystem: '/dev/disk1',
...
}
*/
});
Returns a promise for an array of filesystems with space info.
Returns a promise for an object with the space info for the specified filesystem.
filesystem
- The name of the filesystem.size
- Total size in bytes.used
- Used size in bytes.available
- Available size in bytes.capacity
- Capacity as a float from 0
to 1
.mountpoint
- Disk mount location.Type: string
Returns a promise for an object with the space info for the filesystem the supplied file is part of.
Type: string
MIT © Sindre Sorhus
FAQs
Get free disk space info from `df -kP`
The npm package @sindresorhus/df receives a total of 236,495 weekly downloads. As such, @sindresorhus/df popularity was classified as popular.
We found that @sindresorhus/df demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.