Skip to content

Commit

Permalink
add Promise#resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
aheckmann committed Mar 4, 2011
1 parent 261a8bc commit 5bb3106
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/mongoose/promise.js
Expand Up @@ -117,6 +117,17 @@ Promise.prototype.addBack = function (fn) {
});
};

/**
* Sugar for handling cases where you may be
* resolving to either an error condition or a
* success condition.
*/

Promise.prototype.resolve = function (err, val) {
if (err) return this.error(err);
return this.complete(val);
};

/**
* Module exports.
*/
Expand Down

0 comments on commit 5bb3106

Please sign in to comment.