w3c / FileAPI

File API
https://w3c.github.io/FileAPI/
Other
104 stars 44 forks source link

Add bytes() method to Blob for reading bytes into a Uint8Array #197

Closed bakkot closed 4 months ago

bakkot commented 4 months ago

Edit: Replaced by https://github.com/w3c/FileAPI/pull/198.


The Fetch API is getting a Uint8Array-returning bytes() method alongside its existing arrayBuffer() method, following the principle that APIs should generally vend byte buffers as Uint8Arrays.

This PR makes the same change for Blob, which has its own distinct arrayBuffer method.

I'm assuming this is uncontroversial given the support from the three major implementations for doing this on Body, but I can open an issue and solicit explicit support separately if you'd prefer. I'll write tests if I get a signal that this is able to go forward. Tests written, see link.

Implementation commitment:


Preview | Diff

mkruisselbrink commented 4 months ago

And while getting support signals from implementers is probably not needed for this PR, filing implementation bugs would still be a good thing. (also the IPR bot seems to not know who you are/if you've joined the webapps working group).

bakkot commented 4 months ago

I'll file implementation requests.

Joining W3C working groups is something of a pain, especially just for trivial changes like this. Is there a way to... not do that? If not I am happy to close this and let someone else to make exactly the same change in their own PR. I'll still file the implementation requests.

bakkot commented 4 months ago

Filed the implementation issues, linked in the OP. I didn't check the boxes because they're not technically implementation commitments at the moment.

marcoscaceres commented 4 months ago

Pinged the @siusin for help with getting the IPR commitment on this. Will get it sorted ASAP.

marcoscaceres commented 4 months ago

(worst case, I'll copy/pasta the PR... the change is substantive so we need the commitments)

marcoscaceres commented 4 months ago

wow! great minds think alike 😜: https://github.com/w3c/FileAPI/pull/198

bakkot commented 4 months ago

Thanks!