perf(bundle): drop js-base64

This commit is contained in:
rusconn
2024-09-19 02:59:34 +09:00
parent 90ba9f4f8e
commit f12adfa296
4 changed files with 17 additions and 11 deletions

14
lib/base64.ts Normal file
View File

@@ -0,0 +1,14 @@
export const encode = (s: string) => {
const bytes = new TextEncoder().encode(s);
return btoa(String.fromCharCode(...bytes));
};
export const decode = (base64: string) => {
try {
const binString = atob(base64);
const bytes = Uint8Array.from(binString, c => c.charCodeAt(0));
return new TextDecoder().decode(bytes);
} catch {
return undefined;
}
};