Skip to content

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>>

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:

  • Error Throws an error if there's an issue reading the directory.
ParamTypeDescription
srcPathstringThe 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.

ParamTypeDescription
entryDirectoryEntityThe directory entry to check.

Example

js
const reader = new NodeDirectoryReader();
const isDir = reader.isDirectory(entry);
const reader = new NodeDirectoryReader();
const isDir = reader.isDirectory(entry);

Released under the MIT License.