// package
is-directory
type: "module"
// preferences
// replacements (1)
snippet::is-directory
Simple or drop-in replacementThis package is no longer necessary. You can call `isDirectory()` on the result of `stat` from `node:fs/promises`, or of `statSync` from `node:fs`, treating an `ENOENT` error as `false`.
// example
import { stat } from 'node:fs/promises';
const isDirectory = async (filepath) => {
try {
return (await stat(filepath)).isDirectory();
} catch (err) {
if (err.code === 'ENOENT') return false;
throw err;
}
};