Skip to content

New Proposal: TypeArray encoding #393

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

Closed
wants to merge 1 commit into from

Conversation

jasnell
Copy link
Contributor

@jasnell jasnell commented Jan 19, 2022

Proposes a new API for TypedArray to support built-in hex, base64, base64url, and base32 encoding.

Example:

const u8 = Uint8Array.fromEncodedString('abcdef', 'hex')

console.log(u8.toEncodedString('base64url'))

Currently, each runtime has to handle these differently. Node.js has it's non-standard Buffer API, Deno has its own APIs, browser developers have to choose from a variety of userland options. These encodings are common enough, however, that they warrant being built into the language.

My goal will be to present this at an upcoming TC-39, but also looking for a champion.

@zloirock
Copy link
Contributor

zloirock commented Jan 19, 2022

What's the difference with https://github.com/tc39/proposal-arraybuffer-base64 (sure, excepting place and names of methods)?

@jasnell
Copy link
Contributor Author

jasnell commented Jan 19, 2022

Key difference is the additional support of both hex and base32 and a simpler interface (no options argument with the ability to add other encoding options later)

@ljharb
Copy link
Member

ljharb commented Jan 19, 2022

Typically we only put stage 0 proposals in this repo when they're presented, or planned to be presented, at a TC39 plenary - the deadline has passed for next week's meeting, which means that you can still request advancement but delegates may object solely on the basis of the deadline.

Are you planning to present next week, or in March?

@jasnell
Copy link
Contributor Author

jasnell commented Jan 19, 2022

Likely in March. And there's no rush on getting this PR landed. I wanted to at least open the discussion

@zloirock
Copy link
Contributor

zloirock commented Jan 19, 2022

@jasnell maybe it's better to propose it in the scope of the already existent proposal since they have the same target?

@ljharb
Copy link
Member

ljharb commented Jan 19, 2022

@jasnell you may want to drop the proposal repo link into matrix too.

@ljharb ljharb force-pushed the typedarray-encoding branch from e393943 to fb55f36 Compare January 19, 2022 15:43
@kitsune7
Copy link

I like the idea of adding support for base32 and hex under the ArrayBuffer proposal since it works off the same idea and is a bit farther along. Is it possible to extend the proposal (or add a new one) for ArrayBuffer? We could have additional functions like ArrayBuffer.fromBase32 and ArrayBuffer.fromHex that could follow the same pattern as ArrayBuffer.fromBase64.

@bakkot
Copy link
Contributor

bakkot commented Jan 19, 2022

@kitsune7 I intend to add support for hex, but am unconvinced by the need for base32; see tc39/proposal-arraybuffer-base64#7 (comment). But let's continue the conversation on that repository rather than here.

@ljharb
Copy link
Member

ljharb commented Apr 2, 2022

@jasnell the March meeting has passed; are you intending to propose this at the June meeting?

@ljharb ljharb marked this pull request as draft October 1, 2023 05:29
@ljharb
Copy link
Member

ljharb commented Oct 1, 2023

Closing for now; happy to reopen if you plan to present it in the future.

@ljharb ljharb closed this Oct 1, 2023
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.

5 participants