Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement bytes() method on Blob for reading bytes into a Uint8Array #52972

Open
bakkot opened this issue May 13, 2024 · 12 comments
Open

Implement bytes() method on Blob for reading bytes into a Uint8Array #52972

bakkot opened this issue May 13, 2024 · 12 comments
Labels
experimental Issues and PRs related to experimental features. feature request Issues that request new features to be added to Node.js. web-standards Issues and PRs related to Web APIs

Comments

@bakkot
Copy link

bakkot commented May 13, 2024

See w3c/FileAPI#198. This is like the existing arrayBuffer() method, but gives you a Uint8Array instead.

Tests at web-platform-tests/wpt#46232

See also nodejs/undici#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.

@RedYetiDev RedYetiDev added the web-standards Issues and PRs related to Web APIs label May 13, 2024
@RedYetiDev
Copy link
Member

@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.

@benjamingr
Copy link
Member

@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).

@KhafraDev
Copy link
Member

I won't implement it into fetch until it becomes standardized. I don't think node should land it either until then.

@RedYetiDev
Copy link
Member

RedYetiDev commented May 13, 2024

@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)

@benjamingr
Copy link
Member

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.

@RedYetiDev
Copy link
Member

That's a good point, but either way, I'm not involved in that process, undici handles this, right?

@benjamingr
Copy link
Member

Node handles this for Blob and undici handles it for request/response

@RedYetiDev RedYetiDev added the feature request Issues that request new features to be added to Node.js. label May 14, 2024
@RedYetiDev
Copy link
Member

Thanks for the info. I'm marking this as feature-request, as it is a feature-request.

@RedYetiDev RedYetiDev added the experimental Issues and PRs related to experimental features. label May 14, 2024
@RedYetiDev
Copy link
Member

If implemented, this would be experimental, hence the label

@KhafraDev
Copy link
Member

almost always a good idea

There won't be anything problematic with it 😄.

@KhafraDev
Copy link
Member

it did land in the spec already and I've opened a PR to add it to fetch

@bakkot
Copy link
Author

bakkot commented May 14, 2024

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental Issues and PRs related to experimental features. feature request Issues that request new features to be added to Node.js. web-standards Issues and PRs related to Web APIs
Projects
Status: Pending Triage
Development

No branches or pull requests

4 participants