Skip to content

Commit

Permalink
stage 3!
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Feb 21, 2024
1 parent 826e009 commit d1b5143
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

base64 is a common way to represent arbitrary binary data as ASCII. JavaScript has Uint8Arrays to work with binary data, but no built-in mechanism to encode that data as base64, nor to take base64'd data and produce a corresponding Uint8Arrays. This is a proposal to fix that. It also adds methods for converting between hex strings and Uint8Arrays.

It is currently at Stage 2 of [the TC39 process](https://tc39.es/process-document/).
It is currently at stage 3 of [the TC39 process](https://tc39.es/process-document/): it is ready for implementations. See [this issue](https://github.com/tc39/proposal-arraybuffer-base64/issues/51) for current status.

Try it out on [the playground](https://tc39.github.io/proposal-arraybuffer-base64/).

Expand Down Expand Up @@ -36,7 +36,7 @@ Additional options are supplied in an options bag argument:

- `alphabet`: Allows specifying the alphabet as either `base64` or `base64url`.

- `lastChunkHandling`: Recall that base64 decoding operates on chunks of 4 characters at a time, but the input maybe have some characters which don't fit evenly into such a chunk of 4 characters. This option determines how the final chunk of characters should be handled. The three options are `"loose"` (the default), which treats the chunk as if it had any necessary `=` padding (but throws if this is not possible, i.e. there is exactly one extra character); `"strict"`, which enforces that the chunk has exactly 4 characters (counting `=` padding) and that [overflow bits](https://datatracker.ietf.org/doc/html/rfc4648#section-3.5) are 0; and `"stop-before-partial"`, which stops decoding before the final chunk unless the final chunk has exactly 4 characters.
- `lastChunkHandling`: Recall that base64 decoding operates on chunks of 4 characters at a time, but the input may have some characters which don't fit evenly into such a chunk of 4 characters. This option determines how the final chunk of characters should be handled. The three options are `"loose"` (the default), which treats the chunk as if it had any necessary `=` padding (but throws if this is not possible, i.e. there is exactly one extra character); `"strict"`, which enforces that the chunk has exactly 4 characters (counting `=` padding) and that [overflow bits](https://datatracker.ietf.org/doc/html/rfc4648#section-3.5) are 0; and `"stop-before-partial"`, which stops decoding before the final chunk unless the final chunk has exactly 4 characters.

The hex methods do not take any options.

Expand Down
4 changes: 2 additions & 2 deletions playground/index-raw.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<h1>Proposed Support for Base64 in JavaScript</h1>

<h2 id="introduction">Introduction</h2>
<p>This page documents a stage-2 proposal for native base64 and hex encoding and decoding for binary data in JavaScript, and includes a <strong>non-production</strong> polyfill you can experiment with in the browser's console.</p>
<p>This page documents a stage 3 proposal for native base64 and hex encoding and decoding for binary data in JavaScript, and includes a <strong>non-production</strong> polyfill you can experiment with in the browser's console.</p>
<p>The proposal would provide methods for encoding and decoding Uint8Arrays as base64 and hex strings.</p>
<p>Feedback on <a href="https://github.com/tc39/proposal-arraybuffer-base64">the proposal's repository</a> is appreciated.</p>
<p>Specification text for the proposal is available <a href="https://tc39.es/proposal-arraybuffer-base64/spec/">here</a>.</p>
Expand Down Expand Up @@ -86,7 +86,7 @@ <h3>Basic usage</h3>

<h3>Options</h3>
<p>The base64 methods take an optional options bag which allows specifying the alphabet as either <code>"base64"</code> (the default) or <code>"base64url"</code> (<a href="https://datatracker.ietf.org/doc/html/rfc4648#section-5">the URL-safe variant</a>).</p>
<p>The base64 decoder also allows specifying the behavior for the final chunk with <code>lastChunkHandling</code>. Recall that base64 decoding operates on chunks of 4 characters at a time, but the input maybe have some characters which don't fit evenly into such a chunk of 4 characters. This option determines how the final chunk of characters should be handled. The three options are <code>"loose"</code> (the default), which treats the chunk as if it had any necessary <code>=</code> padding (but throws if this is not possible, i.e. there is exactly one extra character); <code>"strict"</code>, which enforces that the chunk has exactly 4 characters (counting <code>=</code> padding) and that <a href="https://datatracker.ietf.org/doc/html/rfc4648#section-3.5">overflow bits</a> are 0; and <code>"stop-before-partial"</code>, which stops decoding before the final chunk unless the final chunk has exactly 4 characters.
<p>The base64 decoder also allows specifying the behavior for the final chunk with <code>lastChunkHandling</code>. Recall that base64 decoding operates on chunks of 4 characters at a time, but the input may have some characters which don't fit evenly into such a chunk of 4 characters. This option determines how the final chunk of characters should be handled. The three options are <code>"loose"</code> (the default), which treats the chunk as if it had any necessary <code>=</code> padding (but throws if this is not possible, i.e. there is exactly one extra character); <code>"strict"</code>, which enforces that the chunk has exactly 4 characters (counting <code>=</code> padding) and that <a href="https://datatracker.ietf.org/doc/html/rfc4648#section-3.5">overflow bits</a> are 0; and <code>"stop-before-partial"</code>, which stops decoding before the final chunk unless the final chunk has exactly 4 characters.
<p>The hex methods do not have any options.</p>

<pre class="language-js"><code class="language-js">
Expand Down
2 changes: 1 addition & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<pre class="metadata">
title: Uint8Array to/from base64
status: proposal
stage: 2
stage: 3
location: https://github.com/tc39/proposal-arraybuffer-base64
copyright: false
contributors: Kevin Gibbons
Expand Down

0 comments on commit d1b5143

Please sign in to comment.