Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minor refactor, adding a helper function to clean up a promise succes…

…s handler
  • Loading branch information...
commit b8a1f7514171593ce38d8ea20a8180208e380fa4 1 parent 500d4dc
@nrstott authored
Showing with 13 additions and 3 deletions.
  1. +13 −3 lib/router.js
View
16 lib/router.js
@@ -230,9 +230,7 @@ Router.prototype.respond = function(reqPromise) {
promiseArray.push(cb.call(self, req));
});
- return when(Q.all(promiseArray), function() {
- return resp;
- });
+ return when(Q.all(promiseArray), thenResolve(resp));
}, function(err) {
// work around for issue in whenCall, it tries to call rejectCallback even if one is not provided
throw err;
@@ -288,3 +286,15 @@ function stack(/* apps... */) {
}
exports.stack = stack;
+
+/**
+ * Returns a function that returns @param val.
+ *
+ * @param val The value to return
+ * @returns {Function} A function that returns `val`.
+ */
+function thenResolve(val) {
+ return function() {
+ return val;
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.