Implement `bytes()` method on Blob for reading bytes into a Uint8Array
See https://github.com/w3c/FileAPI/pull/198. This is like the existing arrayBuffer() method, but gives you a Uint8Array instead.
Tests at https://github.com/web-platform-tests/wpt/pull/46232
See also https://github.com/nodejs/undici/issues/3256 for the issue for doing the same for Request/Response.
There's also a PR adding the same method to PushMessageData, but I don't think it's relevant to node. Mentioning it here anyway just in case I'm wrong.
@nodejs/web-standards (Summary) this appears to be a future standard, but none of the "big 3" have taken a stance on it yet, but W3C seems to be content with it.
@RedYetiDev blob is a web standard, this method is added to the spec, we should definitely implement it (as experimental and remove experimental status when it lands).
I won't implement it into fetch until it becomes standardized. I don't think node should land it either until then.
@RedYetiDev blob is a web standard, this method is added to the spec, we should definitely implement it (as experimental and remove experimental status when it lands).
I don't think it is standard yet (bytes() atleast), I agree with @KhafraDev's stance. (But, I am not a CODEOWNER)
Implementing before the spec lands is almost always a good idea since it's literally our last realistic chance to request changes or provide feedback when we see an API is problematic.
That's a good point, but either way, I'm not involved in that process, undici handles this, right?
Node handles this for Blob and undici handles it for request/response
Thanks for the info. I'm marking this as feature-request, as it is a feature-request.
If implemented, this would be experimental, hence the label
almost always a good idea
There won't be anything problematic with it 😄.
it did land in the spec already and I've opened a PR to add it to fetch
The Request/Response one landed but Blob - this issue - is technically a different spec, and that PR is still open. (It's slightly more annoying because that spec lives in W3C, unlike fetch, and I haven't gone through the process of joining the relevant W3C working group.)
The Blob PR is now merged.
Just an update on the Big 3
Landed in WebKit: https://github.com/WebKit/WebKit/pull/28657 No comment from Chromium (yet) Confirmed by Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1896509