Async await using Babel
Callbacks, promises, and generators turn out to be the weapons at our disposal to deal with asynchronous code in JavaScript and in Node.js. As we have seen, generators are very interesting because they offer a way to actually suspend the execution of a function and resume it at a later stage. Now we can adopt this feature to write asynchronous code that allows developers to write functions that "appear" to block at each asynchronous operation, waiting for the results before continuing with the following statement.
The problem is that generator functions are designed to deal mostly with iterators and their usage with asynchronous code feels a bit cumbersome. It might be hard to understand, leading to code that is hard to read and maintain.
But there is hope that there will be a cleaner syntax sometime in the near future. In fact, there is an interesting proposal that will be introduced with the ECMAScript 2017 specification that defines the async
function...