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/unstable): toLines() #5121

Merged
merged 7 commits into from
Aug 9, 2024
Merged

Conversation

BlackAsLight
Copy link
Contributor

@BlackAsLight BlackAsLight commented Jun 24, 2024

Closes #5071

Signature: toLines(readable: ReadableStream<Uint8Array>): ReadableStream<string>

Usage

import { toLines } from '@std/streams'

for await (const line of toLines((await Deno.open('./deno.json')).readable))
  console.log('-', line)

Copy link

codecov bot commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.25%. Comparing base (96da26c) to head (7bfb4b7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5121   +/-   ##
=======================================
  Coverage   96.25%   96.25%           
=======================================
  Files         475      476    +1     
  Lines       38464    38475   +11     
  Branches     5584     5584           
=======================================
+ Hits        37023    37034   +11     
  Misses       1399     1399           
  Partials       42       42           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! However, I'm still skeptical about whether this provides sufficient value to justify having it in the Standard Library (weak opinion).

streams/to_lines.ts Outdated Show resolved Hide resolved
streams/to_lines.ts Outdated Show resolved Hide resolved
streams/to_lines.ts Outdated Show resolved Hide resolved
@jsejcksn
Copy link
Contributor

Since this is effectively a functional TransformStream pipe operation, should it accept a pipe options argument (ref: Deno, MDN)? Refer to #5071 (comment) for additional context.

streams/to_lines.ts Outdated Show resolved Hide resolved
BlackAsLight and others added 3 commits June 25, 2024 13:38
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
- Change the return type from `AsyncGenerator<string>` to `ReadableStream<string>`
- Change `readable` to only be of type `ReadableStream<Uint8Array>`
- Add `options` argument of type `PipeOptions.`
@iuioiua iuioiua changed the title feat(streams): add toLines feat(streams): toLines() Jun 25, 2024
@kt3k kt3k changed the title feat(streams): toLines() feat(streams/unstable): toLines() Aug 7, 2024
Copy link
Collaborator

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

I made a few tweaks. Now, LGTM.

@iuioiua iuioiua merged commit d5e3180 into denoland:main Aug 9, 2024
13 checks passed
@BlackAsLight BlackAsLight deleted the to-lines branch August 13, 2024 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature request(streams): lines(readable): AsyncIterable<string>
4 participants