Skip to content

Conversation

@wantaekchoi
Copy link

stream: add bytes() method to stream/consumers

Add a bytes() method to the stream/consumers module that returns a Uint8Array, providing a convenient way to consume streams as typed arrays.

Fixes: #59542

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels Oct 27, 2025
@H4ad H4ad added the semver-minor PRs that contain new features and should be released in the next minor version. label Oct 27, 2025
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.54%. Comparing base (4fe325d) to head (a2b7fe6).
⚠️ Report is 271 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #60426      +/-   ##
==========================================
- Coverage   88.58%   88.54%   -0.05%     
==========================================
  Files         704      703       -1     
  Lines      207823   208301     +478     
  Branches    40049    40168     +119     
==========================================
+ Hits       184101   184438     +337     
- Misses      15772    15868      +96     
- Partials     7950     7995      +45     
Files with missing lines Coverage Δ
lib/stream/consumers.js 100.00% <100.00%> (ø)

... and 136 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wantaekchoi wantaekchoi force-pushed the add-stream-consumers-bytes branch 2 times, most recently from 3887f53 to 4117fc0 Compare October 27, 2025 21:41
- Add bytes() method to get Uint8Array from streams
- Add tests for bytes() method in PassThrough and ObjectMode scenarios
- Update documentation

Fixes: nodejs#59542
@wantaekchoi wantaekchoi force-pushed the add-stream-consumers-bytes branch from 4117fc0 to b6a5a18 Compare October 27, 2025 21:53
Co-authored-by: René <contact.9a5d6388@renegade334.me.uk>
Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

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

This LGTM but I'm not explicitly approving it. I don't know why we really need this when user's could do new Uint8Array(await arrayBuffer(stream)); themselves (or rather any conversion from the raw ArrayBuffer).

@Ethan-Arrowood
Copy link
Contributor

Looking at the issue, I see this is meant to align us with the new bytes() method from fetch spec: https://developer.mozilla.org/en-US/docs/Web/API/Response/bytes

I'm okay with that then :) nice work!

Co-authored-by: jakecastelli <38635403+jakecastelli@users.noreply.github.com>
@Renegade334 Renegade334 added request-ci Add this label to start a Jenkins CI on a PR. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Nov 29, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 29, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@jakecastelli jakecastelli added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. stream Issues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node:stream/consumers should have a bytes method for getting a Uint8Array

7 participants