-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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(std/io): ReadableStream from AsyncIterator & WritableStream from Writer #8378
feat(std/io): ReadableStream from AsyncIterator & WritableStream from Writer #8378
Conversation
@crowlKats can you add some test cases? |
/** Create a `ReadableStream` from an `AsyncIterator`. */ | ||
export function readableStreamFromAsyncIterator<T>( | ||
iterator: AsyncIterableIterator<T>, | ||
): ReadableStream<T> { |
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.
IMO readableStreamFromReader()
should exist either way. This module exists to provide bridges between Deno IO and whatwg streams. One should be able to "expect" a readableStreamFromReader
looking at the other functions.
In this case, there's no problem with having both even if one would have a trivial implementation. Similar to readLines()
in std/io/bufio.ts
.
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.
@nayeemrmn i will look into it soon; the best usage for that would a bytes ReadableStream, but still not knowledgeable about those
I'm missing some context on this PR... what is the purpose of these renames? |
This is not just renames, but rather 2 new functions: one allows to create a ReadableStream from an AsyncIterator and the other allows to create a WritableStream from a Deno.Writer. |
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.
LGTM - thanks @crowlKats
we should also rename
fromStreamWriter
&fromStreamReader
towriterFromStreamWriter
&readerFromStreamReader
.Going to add tests later