Node.js v10 has fs module with promises!

I did not realize that Node.js v10 has promise support for the fs module. Why is this a big thing? It makes it possible to write call-back free code like this:

items = await fs.readdir(path);
for (var i=0; i<items.length; i++) {
  console.log(items[i]);
  }

instead of the older call-back-style:

fs.readdir(path, function(err, items) {
    for (var i=0; i<items.length; i++) {
        console.log(items[i]);
    }
});

Also error handling is so much easier now via a simple try..catch block.

And in case you get the dreaded(?) warning message from node "UnhandledPromiseRejectionWarning: Unhandled promise rejection.", then simply add try..catch blocks or explicit catch handler for promises.