Useful reading to understand the Promises, Generators and the async/await feature for Node.js/JavaScript

Date: Fri Jun 16 2017 Node.JS »»»» JavaScript »»»» Node Web Development
The long-awaited async/await feature for JavaScript promises to make our lives much easier. Instead of asynchronous JavaScript programming being tricky and error-prone, with async/await our code will look like regular synchronous code we write in other languages, but will accommodate asynchronous code execution while retaining the single-threaded nature of JavaScript. With this feature we declare async functions, and within their boundary magic occurs - we can put the "await" keyword in front of a function which produces a Promise, and automagically JavaScript will wait for the Promise to resolve and give us the result or else throw the error. What follows is a list of posts describing how to use async/await.

Click here for more Node.js programming advice

Also included are links to posts about Promises and Generators. Together the three give us a rich tapestry of capabilities to simplify asynchronous programming, make our code look cleaner and more robust.

Write Modern Asynchronous Javascript using Promises, Generators, and Coroutines Shows several ways to use Generators in an Express application. He suggests that since co(function* () { }) is so similar to async functions, and much more widely available, that we should start using those today.

Tips for using async functions (ES2017) An excellent tour of best practices for using async functions.

ES proposal: asynchronous iteration A proposal (don't get too excited yet) for asynchronous looping structures.

Three useful Babel presets Lists several useful Babel tools to enable certain experimental features in JavaScript, including the async/await feature.

promise-sequential "Like Promise.all, but sequentially"

JavaScript Promise API An excellent tour of the Promise object and the best practices for its use.

Understanding JavaScript Promises, Pt. I: Background & Basics A good introduction to Promise's.

Using ES6 array destructing with Promises

The Hidden Power of ES6 Generators: Observable Async Flow Control An in-depth look at Generator functions.

Retrofitting Node/NPM Packages with Async/Await. Rewriting your code to use async/await

Error handling in long Promise chains "The longer the chain the easier it is to break it"

Promises, Promises (or how not to lose your marbles) Some best practices for using Promise's.

Understanding JavaScript’s async await

Installing Babel V6.x ES7 Async/Await on Node.js v6.2.0 with Nodemon A Stack Overflow question about using Babel to transpile async/await

Using ES7 Async/Await in Node.js & Babel.js

Get the value of a Javascript Promise in a synchronous way An excellent discussion of why we need async/await to simplify asynchronous programming in JavaScript

ES7 Async/Await in Node.js with Babel.js

https://tc39.github.io/ecmascript-asyncawait/ - Home page for the committee developing async/await for JavaScript

Node.js Tip - Minimal Babel with Node v6 The precise minimum steps required to setup Babel with Node.js 6.12 to use async/await.