From e2651f76f6e6e93eb0748616136a719d23330c91 Mon Sep 17 00:00:00 2001 From: suyashpotdar Date: Sat, 10 Aug 2024 23:17:23 +0530 Subject: [PATCH] #50749 fs: update documentation in fs.StatsFs --- doc/api/fs.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 7ae55fdd64d214..904ce4e1415988 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -7509,6 +7509,19 @@ added: Free blocks available to unprivileged users. +**Example:** +```javascript +import { statfs } from "fs/promises"; + +async function getAvailableSpace(path) { + const stats = await statfs(path); + const availableSpace = stats.bsize * stats.bavail; // available space in bytes + console.log(`Available space: ${availableSpace} bytes`); +} + +getAvailableSpace("/tmp"); +``` + #### `statfs.bfree`