Skip to content

Commit

Permalink
Refactor base85 encoding and decoding functions to use function decla…
Browse files Browse the repository at this point in the history
…rations
  • Loading branch information
nurliman committed May 8, 2024
1 parent b08f9fd commit cb1be3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-comics-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nurliman/base85": patch
---

Refactor base85 encoding and decoding functions to use function declarations
4 changes: 2 additions & 2 deletions src/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* base85.decode('87cURD]i,"Ebo80');
* // output: Hello World!
*/
export const decodeBase85 = (input: string): string => {
export function decodeBase85(input: string): string {
// Define constants and variables
const ASCII_OFFSET = 33;
const BASE85_BLOCK_SIZE = 5;
Expand Down Expand Up @@ -58,4 +58,4 @@ export const decodeBase85 = (input: string): string => {

// Convert the array of decoded bytes to a string and return it
return String.fromCharCode(...decodedBytes);
};
}
4 changes: 2 additions & 2 deletions src/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type EncodeOptions = {
* base85.encode("Hello World!", { wrap: false });
* // output: 87cURD]i,"Ebo80
*/
export const encodeBase85 = (input: string, { wrap = true }: EncodeOptions = {}): string => {
export function encodeBase85(input: string, { wrap = true }: EncodeOptions = {}): string {
if (!input) return wrap ? "<~~>" : "";

const paddingLength = input.length % 4 || 4;
Expand Down Expand Up @@ -60,4 +60,4 @@ export const encodeBase85 = (input: string, { wrap = true }: EncodeOptions = {})
const output = wrap ? `<~${encodedString}~>` : encodedString;

return output;
};
}

0 comments on commit cb1be3f

Please sign in to comment.