Thanks for the suggestion! I was actually aware of that, but I decided to wrap readFilePromise in a function anyway to illustrate how, after using promisify, we can await the "promisified" function within an async function. I couldn't come up with a better example, but I'll try to think of one to avoid any confusion.
Here, the
readFilePromise
is exactly the same asreadFile
. You could just do:const readFile = util.promisify(fs.readFile);
Thanks for the suggestion! I was actually aware of that, but I decided to wrap
readFilePromise
in a function anyway to illustrate how, after using promisify, we can await the "promisified" function within an async function. I couldn't come up with a better example, but I'll try to think of one to avoid any confusion.I was thinking that this might be the case, but I've decided to comment it out, just in case 😄 Great article!
It's 5am, I couldn't sleep and I came up with a better example that made more sense 😂. I just replaced the old one.