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

BREAKING(io/unstable): remove readLines() #5991

Closed
wants to merge 2 commits into from
Closed

Conversation

iuioiua
Copy link
Collaborator

@iuioiua iuioiua commented Sep 16, 2024

What's changed

readLines() has been removed from @std/io.

Motivation

This change was made to help push users towards using the Streams API and @std/streams, and make design decisions about which APIs easier.

Migration guide

To migrate, use toLines().

- import { readLines } from "@std/io/read-lines";
+ import { toLines } from "@std/streams/unstable-to-lines";
  import { assert } from "@std/assert/assert"

  using file = await Deno.open("README.md");

- for await (const line of readLines(file)) {
+ for await (const line of toLines(file.readable)) {
    assert(typeof line === "string");
  }

Related

Depends on #5990
Towards #5989

@iuioiua iuioiua requested a review from kt3k as a code owner September 16, 2024 06:28
@iuioiua iuioiua enabled auto-merge (squash) September 16, 2024 06:28
@github-actions github-actions bot added the io label Sep 16, 2024
@iuioiua iuioiua marked this pull request as draft September 16, 2024 06:28
auto-merge was automatically disabled September 16, 2024 06:28

Pull request was converted to draft

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.29%. Comparing base (05b6d7e) to head (54c46a8).
Report is 13 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5991   +/-   ##
=======================================
  Coverage   96.29%   96.29%           
=======================================
  Files         493      492    -1     
  Lines       39530    39502   -28     
  Branches     5833     5828    -5     
=======================================
- Hits        38065    38040   -25     
+ Misses       1423     1420    -3     
  Partials       42       42           

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

@BlackAsLight
Copy link
Contributor

In the migration guide here, you're using the using keyword to automatically close the file at the end of the scope, but that isn't needed since you're consuming the .readable property which will also automatically close the file once it hits the end of its stream.

Another person the other day on discord had a bad resource ID error thrown when doing something very similar to this, but that might have been because they weren't consuming the entire readable stream inside the same scope as the file variable.

@iuioiua
Copy link
Collaborator Author

iuioiua commented Sep 17, 2024

I believe not. Consuming the .readable doesn't automatically close the file. Yeah, the issue you point to seems to be something different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants