Node 14


In our working directory, we have an enigma.txt file with the following content:

The elephant is in the room.

In the same working directory, we have the following app.js file:

// app.js
const fs = require('fs');

const path = require('path');
const ENIGMA_FILE = path.join(__dirname, 'enigma.txt');

const callbackReadFile = (file) => {
  fs.readFile(file, 'utf-8', (err, data) => {
    if (err) {
      throw err;
    }
    console.log(data);
  });
};

Create a function promisedReadFile() that "promisifies" the function callbackReadFile(). promisedReadFile() should return a Promise object that resolves the content of the file and rejects the string 'There was an error reading the file'.