fs.readdir reads the content of the directory and fs.readFile reads the content of the file asynchronously. So, here in this code, we will be reading the directory content and then the files in that directory in an asynchronous way.
Here, we are first reading the directory, storing the content of the directory in fileNames and as soon as directory traversing is done, we then start traversing the files of that directory.
Each file is read and after that, the data of that file is pushed back into the dataset.
If you find anything wrong or any other method for this, do mention in the comment section.