UNPKG

vitepress-jsdoc

Version:

A bridge between Vitepress and JSDoc-style commented codebases for hassle-free documentation.

37 lines 1.37 kB
import fs from '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} */ export 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 fs.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(); } } //# sourceMappingURL=node-directory-reader.js.map