Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@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 @sindresorhus/df
import {
diskSpace,
diskSpaceForFilesystem,
diskSpaceForFilesystemOwningPath
} from '@sindresorhus/df';
console.log(await diskSpace());
/*
[
{
filesystem: '/dev/disk1',
type: 'ext4',
size: 499046809600,
used: 443222245376,
available: 55562420224,
capacity: 0.89,
mountpoint: '/'
},
…
]
*/
console.log(await diskSpaceForFilesystem('/dev/disk1'));
/*
{
filesystem: '/dev/disk1',
…
}
*/
console.log(await diskSpaceForFilesystemOwningPath('.'));
/*
{
filesystem: '/dev/disk1',
…
}
*/
Returns a Promise<object[]>
with a list of space info objects for each filesystem.
Returns a Promise<object>
with the space info for the given filesystem path.
filesystem
- Name of the filesystem.type
- Type of the filesystem. (Not available on macOS)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
A path to a filesystem device file. Example: '/dev/disk1'
.
Returns a Promise<object>
with the space info for the filesystem the given path is part of.
Type: string
A path to a file/directory on the filesystem to get the space info for.
FAQs
Get free disk space info from `df -kP`
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.