-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: async iterate readable streams, iterate
function
#30
Conversation
- async iterator on all bluestream readable streams - `iterate(stream)` any readable stream BREAKING CHANGE: dropped the default export
import { Readable } from 'stream' | ||
import { readAsync } from '.' | ||
|
||
if ((Symbol as any).asyncIterator === undefined) { |
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.
This is the syntax that's confusing me the most.
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.
this is a polyfill for the asyncIterator
symbol, since the type Symbol
doesn't have that property we need to cast it to an any
to get it pass lint
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.
oy
throw new TypeError('"stream" is in flowing mode, this is probably not what you want as data loss could occur. Please use stream.pause() to pause the stream before calling readAsync.'); | ||
} | ||
|
||
const inflightRead = inflightReads.get(stream) |
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.
this is some sort of buffer?
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.
Yeah, it defers next readAsync until after the first one finishes so they don't clobber. The weakmap keys the inflight reads on the stream objects themselves and doesn't cause a memory leak like a normal Map would.
iterate(stream)
any readable streamBREAKING CHANGE: dropped the default export