-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Adding async operation support. #27
base: master
Are you sure you want to change the base?
Conversation
f28abf7
to
e7b48f2
Compare
This gets really tricky if someone makes a function that takes a callback and returns a promise. We've struggled with this same issue in async-done and I don't think the complexity of the API is worth it. It almost seems like it should just be a wrapper of some sort. |
I’m leaning towards just making a major that impls the internal _read/write etc with promises instead of cbs. Luckily we don’t have any public apis with cbs exposes on the stream itself so interop is trivial |
@mafintosh have you done any profiling on creating so many intermediate promises? I've not, so I'm just curious. |
It needs to be mutually exclusive. In the implementation as-is I relied on the skill of the programmer (either pass-in a regular fn or a fn returning a promise). I see that this might be a bit naive, so how about adding a guard for regular function to exit with an error or show a warning if a regular function returns a promise (wrong API use). |
e7b48f2
to
4088f7f
Compare
Rebased to match recent changes. In order to address the recent comment: if an async function is detected but no promise is returned, an error will be thrown. |
4088f7f
to
a954a44
Compare
a954a44
to
c837dd8
Compare
This PR adds the option to pass-in
open
,destroy
,read
,write
,writev
, andfinal
asasync
function instead of a callback.