-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add async iterator interface to cursors #371
base: master
Are you sure you want to change the base?
Conversation
Wercker failed even though all tests passed 🤔 |
(error.message.match(/You cannot call `next` on a closed/) === null)) { | ||
return iter.throw(error); | ||
} else { | ||
return iter.return(); |
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.
@mxstbr What other errors might occur? why stop the iterations for only the above errors?
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.
Good question, I copied that from the other places where self._next()
is called. Not sure why it's that specific, honestly!
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.
I suppose it makes sense, since any other errors you might want to ignore where as these don't make sense to continue.
This does raise a question though. With callbacks you get the error and can ignore or handle it.
In this case you wont get it. maybe it should be a part of the return iter.return(err)
.
This also makes me really wonder what errors are possible... I'll ask around.
I came here to do this and was pleasantly surprised to find a PR already open. Now that async iterators are supported natively in node, this would definitely be nice to have, ideally without polyfill. Would it be possible to use the |
Already possible! |
@neumino ? |
See #370, this patch adds a
cursor.asyncIterator
method which returns an async iterator:I added
iterall
as a dependency since I need to use it in the tests anyway, but if you want me to I can move it to thedevDependencies
and inline the$$asyncIterator
polyfill snippet. (it's like 3 lines)