Skip to content

Commit

Permalink
fix: Fix mod.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
redpeacock78 committed Nov 13, 2021
1 parent 35d32a5 commit 1349a68
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ export function base85encode(input: Uint8Array): string {
const mod: number = bit.length % n;
const diff: number = n - mod;
let padding_bit: string = bit;
for (let i: number = 0; i < diff; i++) {
padding_bit = `${padding_bit}00`;
if (mod !== 0) {
for (let i: number = 0; i < diff; i++) {
padding_bit = `${padding_bit}00`;
}
}
const base: number[][] = padding_bit.match(/.{32}/g)!.map((i: string): number[] => {
const con: number = 85;
Expand All @@ -22,7 +24,7 @@ export function base85encode(input: Uint8Array): string {
.flat()
.map((i: number): string => String.fromCharCode(i + 33))
.join("");
return result.match(/!!!!!/) ? `<~${result.replace(/!!!!!/g, "z")}~>` : `<~${result.slice(0, -(diff / 8))}~>`;
return result.match(/!!!!!/) ? `<~${result.replace(/!!!!!/g, "z")}~>` : `<~${result}~>`;
}

// Base85 Decode
Expand All @@ -36,7 +38,7 @@ export function base85decode(str: string): Uint8Array {
if (mod === 0) {
replaced_arr = replaced.match(/.{5}/g)!;
} else {
let padd_replaced = replaced;
let padd_replaced: string = replaced;
for (let i: number = 0; i < diff; i++) {
padd_replaced = `${padd_replaced}u`;
}
Expand Down

0 comments on commit 1349a68

Please sign in to comment.