title: Resolve promise based on another promise
body: <p>I've a function, which returns a promise, inside that I call another function, and the status of this promise is based on the status of the inner promise. </p>
  
  <p>Is there a way to shorthand this process. Look at the example below.</p>
  
  <pre><code>    function foo(bar) {
          var deferred = Q.defer();
  
          switch (bar) {
              case 'baz1':
                  deferred.resolve();
                  break;
              case 'baz2':
                  deferred.reject();
                  break;
              case 'this_is_how_i_do_it':
                  funReturningPromise().then(function (value) {
                      deferred.resolve(value);
                  }, function (err) {
                      deferred.reject(err);
                  });
                  break;
              case 'can_we_do_it_like_this':
                  // can we do something like this, which will resolve or reject the deferred, 
                  // based on the status promise returned by funReturningPromise().
                  // 'chain' is just a name
                  funReturningPromise().chain(deferred);
                  break;
          }
  
          return deferred;
      }
  </code></pre>
  
  <p>Thanks,</p>