doc: Correct note on behavior of stats.isDirectory
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