Optimizing Code Performance and Control Flow Management Using the Async Library

Writing or using functions or methods in your code that are executed one after the other gets you a long way in your applications.

Sometimes, those functions are simple synchronous steps:

console.log('Starting calculation...');
var result = 5 + 4; 
console.log('The result is', result);

Often, callbacks are used when operations are executed in the background and jump back into our code's control flow asynchronously at a later point in time:

console.log('Starting calculation...');
startExpensiveCalculation(5, 4, function(err, result) { 
  if (!err) { 
    console.log('The result is', result);
  }
});

If those asynchronous background operations bring forth a more complex ...

Get The Node Craftsman Book now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.