Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Oct 29, 2023
1 parent 0e4fc1e commit 7d1b5cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion playground/index-raw.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h3>Options</h3>
</code></pre>

<h3>Streaming</h3>
<p>There is no support for streaming. However, it can be implemented in userland.</p>
<p>There is no support for streaming. However, <a href="https://github.com/tc39/proposal-arraybuffer-base64/blob/main/stream.mjs">it can be implemented in userland</a>.</p>

<footer>
<p>Thanks for reading! If you got this far, you should try out the proposal in your browser's developer tools on this page, and submit feedback on <a href="https://github.com/tc39/proposal-arraybuffer-base64">GitHub</a>.</p>
Expand Down
12 changes: 8 additions & 4 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,20 @@ <h1>Uint8Array.fromBase64 ( _string_ [ , _options_ ] )</h1>
1. Let _lastChunkSize_ be _inputLength_ modulo 4.
1. If _lastChunkSize_ is 1, then
1. Throw a *SyntaxError* exception.
1. Else if _lastChunkSize_ is 2 or _lastChunkSize_ is 3, then
1. Append U+0041 (LATIN CAPITAL LETTER A) to _lastChunkSize_ a total of (4 - _lastChunkSize_) times.
1. Let _bytes_ be the unique sequence of bytes such that applying the base64 encoding specified in section 4 of RFC 4648 to that sequence would produce _input_.
1. Let _byteLength_ be the length _bytes_.
1. Else if _lastChunkSize_ is 2, then
1. Append U+0041 (LATIN CAPITAL LETTER A) to _input_ twice.
1. Else if _lastChunkSize_ is 3, then
1. Append U+0041 (LATIN CAPITAL LETTER A) to _input_.
1. Let _bytes_ be the unique (possibly empty) sequence of bytes such that applying the base64 encoding specified in section 4 of RFC 4648 to that sequence would produce _input_.
1. Let _byteLength_ be the length of _bytes_.
1. If _lastChunkSize_ is 2, then
1. If _strict_ is *true* and _bytes_[_byteLength_ - 2] is not 0, throw a *SyntaxError* exception.
1. Remove the final 2 elements of _bytes_.
1. Set _byteLength_ to _byteLength_ - 2.
1. Else if _lastChunkSize_ is 3, then
1. If _strict_ is *true* and _bytes_[_byteLength_ - 1] is not 0, throw a *SyntaxError* exception.
1. Remove the final element of _bytes_.
1. Set _byteLength_ to _byteLength_ - 1.
1. Let _result_ be ? AllocateTypedArray(*"Uint8Array"*, %Uint8Array%, %Uint8Array.prototype%, _byteLength_).
1. Set the value at each index of _result_.[[ViewedArrayBuffer]].[[ArrayBufferData]] to the value at the corresponding index of _bytes_.
1. Return _result_.
Expand Down
2 changes: 1 addition & 1 deletion test-polyfill.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ let illegal = [
'Z+==', // U+FF0B 'Fullwidth Plus Sign'
'Zg\u00A0==', // nbsp
'Zg\u2009==', // thin space
'Zg\u2028==', // thin space
'Zg\u2028==', // line separator
];
test('illegal characters', async t => {
for (let string of malformedPadding) {
Expand Down

0 comments on commit 7d1b5cc

Please sign in to comment.