title: Promises and flow control: Early exit
body: <p>I recently started writing promise code in coffeescript/javascript and I love it. The one thing that I don't understand is how to handle flow control with promises. Consider the  following code with Q.</p>
  
  <pre><code>outerFunction = -&gt;
    Q()
      .then -&gt;
        doSomethingAsync
      .then (result) -&gt;
        return result if result is someSpecialValue 
        #do I really have to continue this chain or nest my promises in a new promise chain?
        ...
      .then -&gt;
        ...
      .then -&gt;
        ...
  </code></pre>
  
  <p>I want to return to the caller early. Is this even possible?</p>
  
  <p>I don't want to use magic exceptions for flow control. Do I need to do something like this or is there a better way?</p>
  
  <pre><code>...
  .then (result) -&gt;
    return result if result is someSpecialValue
    return Q()
      .then -&gt; 
        ...
      .then -&gt; 
        ...
  </code></pre>