-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncify promisified functions #840
Changes from 1 commit
b89b1ac
3c2fd71
ec63006
4be3c68
725fdb2
dbcde70
6f2530b
479d36c
edee839
458c73c
173e913
97f9825
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1186,10 +1186,18 @@ | |
var result; | ||
try { | ||
result = func.apply(this, args); | ||
// if result is Promise object | ||
if (typeof result.then === "function") { | ||
result.then(function(values) { | ||
var args = [null].concat(values); | ||
callback.apply(this, args); | ||
}).catch(callback); | ||
} else { | ||
callback(null, result); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to have the callback call in the try/catch block. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep: The failing test is the one that guards against this: https://travis-ci.org/caolan/async/jobs/70115957 |
||
} | ||
} catch (e) { | ||
return callback(e); | ||
} | ||
callback(null, result); | ||
}); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be only one value from promise so can you do