vitepress-jsdoc
Version:
A bridge between Vitepress and JSDoc-style commented codebases for hassle-free documentation.
44 lines • 1.71 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NodeDirectoryReader = void 0;
const promises_1 = __importDefault(require("node:fs/promises"));
/**
* Represents a directory reader that leverages Node.js's file system module.
* This class provides methods to read directory contents and determine the type of directory entries.
*
* @implements {DirectoryReader}
*/
class NodeDirectoryReader {
/**
* Reads the content of a specified directory and returns its entries.
*
* @param {string} srcPath - The path of the directory to read.
* @returns {Promise<DirectoryEntity[]>} A promise that resolves to an array of directory entries.
* @throws {Error} Throws an error if there's an issue reading the directory.
*
* @example
* const reader = new NodeDirectoryReader();
* const entries = await reader.readDirectory('./src');
*/
async readDirectory(srcPath) {
return promises_1.default.readdir(srcPath, { withFileTypes: true });
}
/**
* Determines whether a given directory entry represents a directory.
*
* @param {DirectoryEntity} entry - The directory entry to check.
* @returns {boolean} Returns true if the entry is a directory, false otherwise.
*
* @example
* const reader = new NodeDirectoryReader();
* const isDir = reader.isDirectory(entry);
*/
isDirectory(entry) {
return entry.isDirectory();
}
}
exports.NodeDirectoryReader = NodeDirectoryReader;
//# sourceMappingURL=node-directory-reader.js.map