Skip to content
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

Merged
merged 3 commits into from
Nov 19, 2020

Conversation

crowlKats
Copy link
Member

we should also rename fromStreamWriter & fromStreamReader to writerFromStreamWriter & readerFromStreamReader.
Going to add tests later

std/io/streams.ts Outdated Show resolved Hide resolved
std/io/streams.ts Outdated Show resolved Hide resolved
std/io/streams.ts Outdated Show resolved Hide resolved
@bartlomieju
Copy link
Member

@crowlKats can you add some test cases?

Comment on lines +49 to +52
/** Create a `ReadableStream` from an `AsyncIterator`. */
export function readableStreamFromAsyncIterator<T>(
iterator: AsyncIterableIterator<T>,
): ReadableStream<T> {
Copy link
Collaborator

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.

Copy link
Member Author

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

@ry
Copy link
Member

ry commented Nov 19, 2020

I'm missing some context on this PR... what is the purpose of these renames?

@crowlKats
Copy link
Member Author

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.
The renames are there just because it would make differentiating the functions easier; fromStreamWriter is too vague, but writerFromStreamWriter gives enough context on what it does.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks @crowlKats

@ry ry merged commit 723fbb8 into denoland:master Nov 19, 2020
@crowlKats crowlKats deleted the streams_from_writer_&_async_iter branch November 19, 2020 12:48
jannes pushed a commit to jannes/deno that referenced this pull request Dec 1, 2020
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 21, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants