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): remove LimitedReader #6058

Merged
merged 1 commit into from
Sep 26, 2024
Merged

BREAKING(io): remove LimitedReader #6058

merged 1 commit into from
Sep 26, 2024

Conversation

iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Sep 25, 2024

What's changed

LimitedReader 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

Note: the deprecation notice for readDelim() says to use LimitedByteTransformStream. This is incorrect. Instead, migrate using the instructions below.

To migrate, pipe the readable stream through a ByteSliceStream, setting start to 0, and end to 1 less than that of limit in LimitedReader.

- import { LimitedReader } from "@std/io/limited-reader";
- import { readAll } from "@std/io/read-all";
+ import { ByteSliceStream } from "@std/streams/byte-slice-stream";
+ import { toText } from "@std/streams/to-text";

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

- const reader = new LimitedReader(file, 10);
+ const stream = file.readable.pipeThrough(new ByteSliceStream(0, 9));

- console.log(new TextDecoder().decode(await readAll(reader))); // "# Deno Sta"
+ console.log(await toText(stream)); // "# Deno Sta"

Related

Towards #5989

@iuioiua iuioiua requested a review from kt3k as a code owner September 25, 2024 04:33
@github-actions github-actions bot added the io label Sep 25, 2024
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

@iuioiua iuioiua merged commit 6c75ccb into main Sep 26, 2024
18 checks passed
@iuioiua iuioiua deleted the remove-LimitedReader branch September 26, 2024 01:51
eryue0220 added a commit to eryue0220/deno_std that referenced this pull request Sep 26, 2024
…deno_std into feat/expect-object-containing

* 'feat/expect-object-containing' of github.com:eryue0220/deno_std:
  BREAKING(io): remove `StringReader` (denoland#6062)
  BREAKING(io): remove `StringWriter` (denoland#6061)
  BREAKING(io): remove `MultiReader` (denoland#6059)
  BREAKING(io): remove `LimitedReader` (denoland#6058)
  chore: fix heading level in Releases.md (denoland#6044)
  BREAKING(io): remove `readDelim()` (denoland#6052)
  BREAKING(io): remove `BufWriter` (denoland#6057)
  BREAKING(io): remove `BufReader` (denoland#6056)
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