code: function deferPromise() {
      var resolve = null, reject = null;
      var promise = new Bluebird(function () {
          resolve = arguments[0];
          reject = arguments[1];
      });
      return {
          resolve: resolve,
          reject: reject,
          promise: promise
      };
  }
docs: Defer Promise
  @returns {{resolve: *, reject: *, promise}}