Let’s get modular

Now let’s use your newly found knowledge about modules.

You will now create a new module and also use some of NodeJS’s built-in modules. The module should be able to return a list of all the rows in all the files in a specified folder. Your module should be able to do that Synchronously and Asynchronously.

Your module should:

For example:

Use the built in node module called fs - it stands for File System. The fs module handles accessing files from Node.JS.

You should use these 2 function calls from the fs module in your module:

You will need to pass in the encoding of utf8 as an option parameter to readFileSync otherwise a buffer will be returned instead of the string value.

You can read more about the fs module at the Node API documentation.

The module should be in a file called: