title: async.waterfall in a For Loop in Node.js
body: <p>When using <a href="https://github.com/caolan/async" rel="noreferrer"><code>async.waterfall</code></a> within a <code>for</code> loop, it appears that the <code>for</code> loop iterates before the nested <code>async.waterfall</code> finishes all its steps. How can this be avoided?</p>
  
  <pre><code>for(var i = 0; i &lt; users.length; i++ ) {
  
      console.log(i)
  
      async.waterfall([
          function(callback) {
              callback(null, 'one', 'two');
          },
          function(arg1, arg2, callback) {
            // arg1 now equals 'one' and arg2 now equals 'two'
              callback(null, 'three');
          },
          function(arg1, callback) {
              // arg1 now equals 'three'
              callback(null, 'done');
          }
      ], function (err, result) {
          // result now equals 'done'
          console.log('done')
      });
  
  
  }
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>0
  1
  2
  3
  4
  done
  done
  done
  done
  done
  </code></pre>
  
  <p><strong>Desired Output</strong></p>
  
  <pre><code>0
  done
  1
  done
  2
  done
  3
  done
  4
  done
  </code></pre>