Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Apr 3, 2022
1 parent 5934413 commit cb771d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions docs/base64.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ <h1 class="page-title">
<article>
<pre class="prettyprint source linenums"><code>/* ------------------------------------------------------------------------------------

base64 - MIT License - Hexagon &lt;github.com/Hexagon>
base64 - MIT License - Hexagon &lt;hexagon@56k.guru>

------------------------------------------------------------------------------------

License:

Copyright (c) 2021 Hexagon &lt;github.com/Hexagon>
Copyright (c) 2021 Hexagon &lt;hexagon@56k.guru>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -252,21 +252,23 @@ <h1 class="page-title">
* @public
*
* @param {string} str - Base64 encoded string to be decoded
* @param {boolean} [urlMode] - If set to true, URL mode string will be expected
* @returns {string} - Decoded string
*/
base64.toString = (str, urlMode) => {
return Buffer.from(base64.toArrayBuffer(str, urlMode)).toString();
return new TextDecoder().decode(base64.toArrayBuffer(str, urlMode));
};

/**
* Convenience function for converting a javascript string to base64
* @public
*
* @param {string} str - String to be converted to base64
* @param {boolean} [urlMode] - If set to true, URL mode string will be returned
* @returns {string} - Base64 encoded string
*/
base64.fromString = (str, urlMode) => {
return base64.fromArrayBuffer(Buffer.from(str), urlMode);
return base64.fromArrayBuffer(new TextEncoder().encode(str), urlMode);
};

export default base64;
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ <h1>
<h1>@hexagon/base64</h1>
<p>Base64 and base64url to string or arraybuffer, and back. Works in Node, Deno or browser.</p>
<p><a href="https://github.com/Hexagon/base64/actions/workflows/node.js.yml"><img src="https://github.com/Hexagon/base64/actions/workflows/node.js.yml/badge.svg" alt="Node.js CI"></a>
<a href="https://badge.fury.io/js/@hexagon%2Fbase64"><img src="https://badge.fury.io/js/@hexagon%2Fbase64.svg" alt="npm version"></a> <a href="https://www.npmjs.org/package/@hexagon/base64"><img src="https://img.shields.io/npm/dm/@hexagon/base64.svg" alt="NPM Downloads"></a> <a href="https://www.codacy.com/gh/Hexagon/base64/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Hexagon/base64&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/4978bdbf495941c087ecb32b120f28ff" alt="Codacy Badge"></a>
<a href="https://github.com/Hexagon/base64/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License"></a> <a href="https://www.jsdelivr.com/package/gh/hexagon/base64"><img src="https://data.jsdelivr.com/v1/package/gh/hexagon/base64/badge?style=rounded" alt="jsdelivr"></a></p>
<a href="https://badge.fury.io/js/@hexagon%2Fbase64"><img src="https://badge.fury.io/js/@hexagon%2Fbase64.svg" alt="npm version"></a> <a href="https://www.npmjs.org/package/@hexagon/base64"><img src="https://img.shields.io/npm/dm/@hexagon/base64.svg" alt="NPM Downloads"></a> <a href="https://www.jsdelivr.com/package/npm/@hexagon/base64"><img src="https://data.jsdelivr.com/v1/package/npm/@hexagon/base64/badge?style=rounded" alt="jsdelivr"></a> <a href="https://www.codacy.com/gh/Hexagon/base64/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Hexagon/base64&amp;utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/4978bdbf495941c087ecb32b120f28ff" alt="Codacy Badge"></a>
<a href="https://github.com/Hexagon/base64/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License"></a></p>
<ul>
<li>Supports regular base64, as well as base64url</li>
<li>Convert to/from string or arraybuffer</li>
Expand Down

0 comments on commit cb771d9

Please sign in to comment.