Skip to content

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

@bakkot

Description

@bakkot

Node has some utilities for fully consuming streams (web or otherwise, though for some reason these are only documented in the webstreams docs page).

Specifically, it offers arrayBuffer, blob, buffer, json, and text, intended to mirror the similar methods on the Body mixin on the web (which is what provides these methods for e.g. fetch responses).

Since then, the Body mixin has gained a new bytes method which gives you a Uint8Array. The same should be added here to match.

Note that there is still discussion of adding similar methods to web streams natively, but there's no firm implementer interest except from Bun. But if they eventually ship natively a bytes method will beincluded.

This is probably a good first issue; the original PR plus the followup docs PR are pretty small.

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions