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

feat: add Host.arrayBufferToBase64 and Host.base64ToArrayBuffer #94

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

chrisdickinson
Copy link
Contributor

No description provided.

@chrisdickinson chrisdickinson requested a review from bhelx September 9, 2024 18:58
@bhelx
Copy link
Contributor

bhelx commented Sep 9, 2024

I think this is a reasonable approach. I'd like to go back eventually and add btoa support, etc. i'll add a ticket for it.

@nilslice
Copy link
Member

nilslice commented Sep 9, 2024

curious if we can wrap these in the JS prelude to make the literal builtin atob work

EDIT: just saw @bhelx track #95

If its just the matter of providing a wrapper around these new Rust functions in JS, should we do it now?

@chrisdickinson
Copy link
Contributor Author

chrisdickinson commented Sep 9, 2024

If its just the matter of providing a wrapper around these new Rust functions in JS, should we do it now?

Ah, it's not – atob and btoa are legacy web platform APIs (added in the first version, I think!) They're pretty inefficient – in order to work with them you end up having to copy buffer data into or out of a string first (so you end up with 2 copies of the buffer + 1 copy of the encoded buffer.) They also don't work super well with Unicode, so it's tricky to roundtrip through the APIs. Most JS platforms add some method for encoding to and decoding from base64 as a result.

@nilslice
Copy link
Member

nilslice commented Sep 9, 2024

TIL! thank you

Copy link
Member

@nilslice nilslice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- if @chrisdickinson is unable, I would like to merge this and use asap!

@bhelx bhelx merged commit e066a06 into main Sep 9, 2024
8 checks passed
@bhelx bhelx deleted the chris/20240909-base64d branch September 9, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants