-
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
Conversation
if (typeof result.then === "function") { | ||
result.then(function(values) { | ||
var args = [null].concat(values); | ||
callback.apply(this, args); |
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
callback.call(this, value)
👍 can you add some unit tests (feel free to add a dev dependency for some promise implementation, e.g. NPO/rsvp/bluebird/es6-promise) |
callback.apply(this, args); | ||
}).catch(callback); | ||
} else { | ||
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.
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 comment
The 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
unit tests for es6-promise and rsvp
Conflicts: package.json
Done! |
'es6-promise', | ||
'rsvp' | ||
].reduce(function(promises, name) { | ||
var Promise = require(name); |
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.
You might want to make these tests node-only, because this won't work in the browser.
I think node-only for a while, but all tested promise libraries differently support browsers. |
It's not the promise implementation, but the |
Most of Promise realisations doesn't contain
nodeify
method. Here is extention of async wrapper for promisified functions.For example promise-styled openpgp library functions looks like
And can be easily wrapped to use with favourite async:)