proposals
proposals copied to clipboard
New Proposal: TypeArray encoding
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.
What's the difference with https://github.com/tc39/proposal-arraybuffer-base64 (sure, excepting place and names of methods)?
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)
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?
Likely in March. And there's no rush on getting this PR landed. I wanted to at least open the discussion
@jasnell maybe it's better to propose it in the scope of the already existent proposal since they have the same target?
@jasnell you may want to drop the proposal repo link into matrix too.
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.
@kitsune7 I intend to add support for hex, but am unconvinced by the need for base32; see https://github.com/tc39/proposal-arraybuffer-base64/issues/7#issuecomment-872536851. But let's continue the conversation on that repository rather than here.
@jasnell the March meeting has passed; are you intending to propose this at the June meeting?
Closing for now; happy to reopen if you plan to present it in the future.