Skip to content

Commit

Permalink
fix(typescript): get rid of 3rd party base64 lib
Browse files Browse the repository at this point in the history
  • Loading branch information
krvital committed Nov 22, 2024
1 parent 38ebacc commit 2521cbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 10 additions & 4 deletions resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import base64 from '@juanelas/base64';

import {
HttpClientInstance,
httpClient as http,
Expand All @@ -20,11 +18,19 @@ import {
export { HTTPError };

export function decode(str: string): string {
return base64.decode(str, true).toString();
if (typeof window == 'undefined') {
return Buffer.from(str, "base64").toString();
} else {
return atob(str);
}
}

export function encode(str: string): string {
return base64.encode(str);
if (typeof window == 'undefined') {
return Buffer.from(str).toString('base64');
} else {
return btoa(str);
}
}

export const sleep = (ms: number) =>
Expand Down
1 change: 0 additions & 1 deletion resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"@juanelas/base64": "^1.1.2",
"tslib": "^2.6.1"
},
"devDependencies": {
Expand Down

0 comments on commit 2521cbc

Please sign in to comment.