-
Notifications
You must be signed in to change notification settings - Fork 8
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
Check 'end' and 'error' events in fromStream() #2
Conversation
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.
Oh sweet, I’ll check it out as soon as I can but it reads really well.
I don't like this for one reason
The reason is no other iterators have this restriction, and I'd rather special case the various kinds of streams than force a different model. For example function* numbers () {
yield 1
yield 2
yield 3
}
const nums = numbers()
for (const num of nums) {
console.log('should print', num)
}
for (const num of nums) {
console.log(`shouldn't print`, num)
} However you left the test |
rebase/merge master and you'll have CI |
Remove access to private _readableState, which may be missing from third-party stream implementations. Assumes non-ended streams are passed, in paused mode, in which case 'end' is emitted after read() is called. Fixes reconbot#1.
Before Node.js 12.9.0 there was no sanctioned API for determining whether a stream had ended. Happy to add that as a check, though this assumption would still apply to non-conformant streams. We could retain the previous check as well, though with some guards to avoid crashes. I don't see how this relates to other iterators.
That just happens to be how pass-through streams work. The |
7434a7b
to
e000265
Compare
I've rebased but I'm not sure if GitHub is picking up the CI run. Maybe because this PR predates it. It may work if you push these commits to the main repo. |
Hey sorry this drifted a bit since you opened it. I wasn’t able to reason about it at the time and I’m not sure I like the assumption it requires. So I’m going to close it for now. |
Remove access to private
_readableState
, which may be missing from third-party stream implementations.Assumes non-ended streams are passed, in paused mode, in which case
end
is emitted afterread()
is called.Fixes #1.
I realize the commit messages are not in the expected format, but I reckon you can fix that in a squash merge 😉