docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a utility that reads and returns the contents of directories in an in-memory filesystem.
Implement two functions that work with an in-memory filesystem instance:
listDirectoryContents(fs, dirPath) - Returns an array of entry names (files and subdirectories) from the specified directory pathcountEntriesInDirectory(fs, dirPath) - Returns the total count of entries in the specified directory pathBoth functions should:
/**
* Lists all entries in the specified directory path.
* @param {Object} fs - The memory filesystem instance
* @param {string} dirPath - Path to the directory
* @returns {string[]} Array of entry names sorted alphabetically
* @throws {Error} Throws error if directory does not exist
*/
function listDirectoryContents(fs, dirPath) {
// IMPLEMENTATION HERE
}
/**
* Counts the number of entries in a directory.
* @param {Object} fs - The memory filesystem instance
* @param {string} dirPath - Path to the directory
* @returns {number} Number of entries in the directory
* @throws {Error} Throws error if directory does not exist
*/
function countEntriesInDirectory(fs, dirPath) {
// IMPLEMENTATION HERE
}
module.exports = {
listDirectoryContents,
countEntriesInDirectory,
};Provides in-memory filesystem operations for testing.