Skip to content

add a method to get a Uint8Array to Body #1732

Closed
@bakkot

Description

@bakkot

What problem are you trying to solve?

Body has an .arrayBuffer() method, but that's almost never what you actually want, since you can't read out of a buffer directly - you need a view. Uint8Array is the canonical "sequence of byte values" view.

What solutions exist today?

new Uint8Array(await body.arrayBuffer())

How would you solve it?

Add a .bytes() method which gives a new Uint8Array.

Anything else?

Some brief discussion here.

PushMessageData and Blob (which live elsewhere) would need this too, since they just copied Body.

(Also, watch out for #1675 while specifying.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions