Skip to content

Files

Latest commit

b04211b · Aug 1, 2023

History

History
28 lines (21 loc) · 1 KB

README.md

File metadata and controls

28 lines (21 loc) · 1 KB

node-statvfs

This module provides Node.js bindings for the uv_fs_statfs() function.

Example

const { statvfs, statvfsSync } = require('@wwa/statvfs');

// Asynchronous API, uses uv_fs_statfs()
statvfs('/').then((stat) => {
    console.log('Total space:', stat.blocks * stat.bsize / 1073741824, 'GiB');
    console.log('Free space:', stat.bfree * stat.bsize / 1073741824, 'GiB');
    console.log('Available space:', stat.bavail * stat.bsize / 1073741824, 'GiB');

    console.log('Total inodes:', stat.files);
    console.log('Free inodes:', stat.ffree);
});

// Synchronous API (since 1.1.0), uses statvfs()
const stat = statvfsSync('/');
console.log('Total space:', stat.blocks * stat.bsize / 1073741824, 'GiB');
console.log('Free space:', stat.bfree * stat.bsize / 1073741824, 'GiB');
console.log('Available space:', stat.bavail * stat.bsize / 1073741824, 'GiB');

console.log('Total inodes:', stat.files);
console.log('Free inodes:', stat.ffree);