node-directory-reader
NodeDirectoryReader
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.
Kind: global class
Implements: DirectoryReader
- NodeDirectoryReader
- .readDirectory(srcPath) ⇒
Promise.<Array.<DirectoryEntity>> - .isDirectory(entry) ⇒
boolean
- .readDirectory(srcPath) ⇒
nodeDirectoryReader.readDirectory(srcPath) ⇒ Promise.<Array.<DirectoryEntity>>
Reads the content of a specified directory and returns its entries.
Kind: instance method of NodeDirectoryReader
Returns: Promise.<Array.<DirectoryEntity>> - A promise that resolves to an array of directory entries.
Throws:
ErrorThrows an error if there's an issue reading the directory.
| Param | Type | Description |
|---|---|---|
| srcPath | string | The path of the directory to read. |
Example
js
const reader = new NodeDirectoryReader();
const entries = await reader.readDirectory('./src');const reader = new NodeDirectoryReader();
const entries = await reader.readDirectory('./src');nodeDirectoryReader.isDirectory(entry) ⇒ boolean
Determines whether a given directory entry represents a directory.
Kind: instance method of NodeDirectoryReader
Returns: boolean - Returns true if the entry is a directory, false otherwise.
| Param | Type | Description |
|---|---|---|
| entry | DirectoryEntity | The directory entry to check. |
Example
js
const reader = new NodeDirectoryReader();
const isDir = reader.isDirectory(entry);const reader = new NodeDirectoryReader();
const isDir = reader.isDirectory(entry);