Skip to content

doc: Correct note on behavior of stats.isDirectory

Rodrigo Muino Tomonari requested to merge github/fork/NReilingh/patch-1 into main

Original author incorrectly assumed that lstat can only be used on symbolic links

The note incorrectly stated that .isDirectory() always returns false when the stats object was obtained from fs.lstat(). lstat can be used on any type of object -- not just symbolic links. When stats are obtained using lstat for a regular directory (not a link), .isDirectory() will return true.

$ mkdir -p /tmp/foo
const fs = require('fs');
const lstats = await fs.promises.lstat('/tmp/foo');
lstats.isDirectory(); // true

Merge request reports

Loading