title: Is there a better async coding pattern?
body: <p>If I have only synchronous functions and:</p>
  
  <pre><code>var err = f1();
  if (err)
     xxxx
  else
     yyyy;
  </code></pre>
  
  <p>and I need to add another function call which is dependent on the first having completed successfully, I can just append it:</p>
  
  <pre><code>var err = f1(a);
  if (err)
     xxxx
  else {
     yyyy;
  
     var err2 = f2(b);
     if (err2)
        ...
     else
        rrr;
  }
  </code></pre>
  
  <p>But when the functions are asynchronous, I would initially have:</p>
  
  <pre><code>f1(a, function(err) {
     if (err)
        xxxx
     else 
        yyy;
  });
  </code></pre>
  
  <p>Adding the second call would require some surgery, lots of braces and parentheses to trace:</p>
  
  <pre><code>f1(a, function(err) {
     if (err)
        xxxx
     else {
        yyy;
        f2(b, function(err) {
          if (err)
            ...
          else
            rrr;
        });
     }
  });
  </code></pre>
  
  <p>Adding a third is even more painful and time consuming. Am I missing out on a smarter way?</p>