code: function promiseWrap(x) {
    if(x.then && typeof x.then === "function") {
      return x;    
    }
    var deferred = q.defer();
    deferred.resolve(x);
    return deferred.promise;
  }
docs: wrap non-promises in a promise for api simplicity