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: streams utilities #1141

Merged
merged 25 commits into from
Oct 12, 2021
Merged

feat: streams utilities #1141

merged 25 commits into from
Oct 12, 2021

Conversation

crowlKats
Copy link
Member

@crowlKats crowlKats commented Aug 18, 2021

TODO:

  • add examples for merge.ts will add examples in a separate PR once the new subprocess API lands

@crowlKats
Copy link
Member Author

One issue is that readerFromIterable which returns a Deno.Reader would be moved to streams folder as well. do we want to have io/conversion.ts for that?

@nayeemrmn
Copy link
Contributor

If you think about it almost everything in std/io revolves around streams, including utilities to convert them between formats (e.g. readableStreamFromReader()), collect them (e.g. readAll()), etc. Things like Buffer exist to hold data for the purpose of appending to / consuming from it with stream APIs. Once go-like stream interfaces are fully deprecated/removed from CLI, most of std/io should be nuked at that point and rebuilt fully around whatwg streams effectively becoming the one proposed here.

In fewer words, std/io is currently in a very messy state and we should avoid potentially spreading that outwards until 2.0 APIs drop and we have a clear picture of what to do with it. The new utilities you have are good and would survive CLI stream overhauls, so for now I would just throw them all in io/streams.ts.

@crowlKats
Copy link
Member Author

Not sure whats going wrong with CI in an unrelated module. testing locally works fine

@lucacasonato
Copy link
Member

@crowlKats Could you rebase this? I'd love to land it.

# Conflicts:
#	io/README.md
#	io/mod.ts
#	streams/conversion.ts
#	streams/conversion_test.ts
Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

I am pretty happy with this. I'd love to get it landed before the release tomorrow.

@nayeemrmn or @kt3k do you have any strong objections?

Copy link
Contributor

@nayeemrmn nayeemrmn left a comment

Choose a reason for hiding this comment

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

No objections. Thinking further about it std/streams makes more sense to have than std/io, but I still think their scopes almost completely overlap and we should consider moving lots of other stuff over as well e.g. readLines(), even the buffering utilities are revolved around streams.

Copy link
Contributor

@nayeemrmn nayeemrmn left a comment

Choose a reason for hiding this comment

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

LGTM

@kt3k
Copy link
Member

kt3k commented Oct 12, 2021

Is it intentional to put copy, readAll, readAllSync, writeAll, writeAllSync in streams/conversion.ts? These don't seem involving Streams, so it seems a little strange to me. Maybe we should keep them somewhere in io/?

Otherwise this looks good to me.

@nayeemrmn
Copy link
Contributor

Is it intentional to put copy, readAll, readAllSync, writeAll, writeAllSync in streams/conversion.ts? These don't seem involving Streams, so it seems a little strange to me. Maybe we should keep them somewhere in io/?

I believe it's streams as in general io streams, not specifically whatwg streams. So Reader and Writer should count.

@kt3k
Copy link
Member

kt3k commented Oct 12, 2021

I believe it's streams as in general io streams, not specifically whatwg streams. So Reader and Writer should count.

Ok. Then it's fine

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM

@crowlKats
Copy link
Member Author

crowlKats commented Oct 12, 2021

Is it intentional to put copy, readAll, readAllSync, writeAll, writeAllSync in streams/conversion.ts? These don't seem involving Streams, so it seems a little strange to me. Maybe we should keep them somewhere in io/?

I believe it's streams as in general io streams, not specifically whatwg streams. So Reader and Writer should count.

it kinda is more targeted towards whatwg streams, but since deprecating go-like streams isnt that far off, i think its fine to have those functions there for now, especially as some functions would make sense in both to some degree

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

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

Thanks @crowlKats!

@lucacasonato lucacasonato merged commit b58b10c into denoland:main Oct 12, 2021
@crowlKats crowlKats deleted the streams branch October 12, 2021 10:29
traceypooh pushed a commit to traceypooh/deno_std that referenced this pull request Nov 14, 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.

4 participants