diff --git a/doc/api/fs.md b/doc/api/fs.md index 186ab76c0989..266242fcdc42 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -7994,6 +7994,9 @@ i.e. before the `'ready'` event is emitted. + +* `value` {any} +* Returns: {boolean} + +Returns `true` if `value` is a `fs.Stats` object, including objects returned +when `bigint` option was set to `true`. Returns `false` otherwise. + +Prefer this method over `value instanceof fs.Stats`. + +```mjs +import { statSync, Stats } from 'node:fs'; + +const stats = statSync('/etc/hosts'); +const statsBigInt = statSync('/etc/hosts', { bigint: true }); + +Stats.isStats(stats); // true +Stats.isStats(statsBigInt); // true +stats instanceof Stats; // true +statsBigInt instanceof Stats; // false +``` + +```cjs +const { statSync, Stats } = require('node:fs'); + +const stats = statSync('/etc/hosts'); +const statsBigInt = statSync('/etc/hosts', { bigint: true }); + +Stats.isStats(stats); // true +Stats.isStats(statsBigInt); // true +stats instanceof Stats; // true +statsBigInt instanceof Stats; // false +``` + #### `stats.isBlockDevice()`