Skip to content

Commit 5fb7148

Browse files
committed
doc: add examples for fs.StatFs properties
Adds documentation examples for fs.StatFs properties (bavail, bfree, blocks, bsize, type). Fixes: #50749
1 parent bf992e8 commit 5fb7148

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

doc/api/fs.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8004,6 +8004,14 @@ added:
80048004
80058005
Free blocks available to unprivileged users.
80068006
8007+
```mjs
8008+
import { statfs } from 'node:fs/promises';
8009+
8010+
const stats = await statfs('/');
8011+
const availableSpaceInBytes = stats.bsize * stats.bavail;
8012+
```
8013+
8014+
80078015
#### `statfs.bfree`
80088016
80098017
<!-- YAML
@@ -8016,6 +8024,14 @@ added:
80168024
80178025
Free blocks in file system.
80188026
8027+
```mjs
8028+
import { statfs } from 'node:fs/promises';
8029+
8030+
const stats = await statfs('/');
8031+
const freeSpaceInBytes = stats.bsize * stats.bfree;
8032+
```
8033+
8034+
80198035
#### `statfs.blocks`
80208036
80218037
<!-- YAML
@@ -8028,6 +8044,14 @@ added:
80288044
80298045
Total data blocks in file system.
80308046
8047+
```mjs
8048+
import { statfs } from 'node:fs/promises';
8049+
8050+
const stats = await statfs('/');
8051+
const totalSpaceInBytes = stats.bsize * stats.blocks;
8052+
```
8053+
8054+
80318055
#### `statfs.bsize`
80328056
80338057
<!-- YAML
@@ -8038,7 +8062,7 @@ added:
80388062
80398063
* Type: {number|bigint}
80408064
8041-
Optimal transfer block size.
8065+
Optimal transfer block size in bytes.
80428066
80438067
#### `statfs.frsize`
80448068
@@ -8088,6 +8112,8 @@ added:
80888112
80898113
Type of file system.
80908114
8115+
This is an OS-dependent numeric value representing the file system type.
8116+
80918117
### Class: `fs.Utf8Stream`
80928118
80938119
<!-- YAML

0 commit comments

Comments
 (0)