(str: string)
| 21 | * non-ASCII characters by first encoding the string as UTF-8. |
| 22 | */ |
| 23 | export const toBase64 = (str: string): string => { |
| 24 | const bytes = new TextEncoder().encode(str); |
| 25 | const binary = Array.from(bytes, (b) => String.fromCharCode(b)).join(""); |
| 26 | return btoa(binary); |
| 27 | }; |
| 28 | |
| 29 | const kilobyte = 1024n; |
| 30 | const megabyte = 1024n * 1024n; |
no test coverage detected