Practice how to write an asynchronous function that returns the list of the files that are in the directory and subdirectories.
Problem statement
Write a listNestedFiles()
named callback-style function that takes, as the input, the path to a directory in the local filesystem and that asynchronously iterates over all the subdirectories to eventually return a list of all the files discovered. Here’s what the signature of the function should look like:
function listNestedFiles (dir, cb) { /* ... */ }
Bonus points if you manage to avoid callback hell. Feel free to create additional helper functions if needed.