Skip to content

Commit

Permalink
Add type annotation to base encoding/decoding examples.
Browse files Browse the repository at this point in the history
Co-authored-by: Dave Longley <[email protected]>
  • Loading branch information
wes-smith and dlongley authored Jun 9, 2024
1 parent 79c54b5 commit 38d2077
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2901,6 +2901,12 @@ <h2>Base Encode</h2>
</ol>

<pre class="example" title="An implementation of the general base-encoding algorithm above in Javascript">
/**
* @param {Uint8Array} bytes
* @param {number} targetBase
* @param {string} baseAlphabet
* @returns string
*/
function baseEncode(bytes, targetBase, baseAlphabet) {
let zeroes = 0;
let length = 0;
Expand Down Expand Up @@ -3049,6 +3055,12 @@ <h2>Base Decode</h2>
</ol>

<pre class="example" title="An implementation of the general base-decoding algorithm above in Javascript">
/**
* @param {string} sourceEncoding
* @param {number} sourceBase
* @param {string} baseAlphabet
* @returns Uint8Array
*/
function baseDecode(sourceEncoding, sourceBase, baseAlphabet) {
// build the base-alphabet to integer value map
baseMap = {};
Expand Down

0 comments on commit 38d2077

Please sign in to comment.