(input: Uint8Array)
| 1 | export function encodeBase64(input: Uint8Array): string { |
| 2 | // @ts-ignore |
| 3 | if (Uint8Array.prototype.toBase64) { |
| 4 | // @ts-ignore |
| 5 | return input.toBase64() |
| 6 | } |
| 7 | |
| 8 | const CHUNK_SIZE = 0x8000 |
| 9 | const arr = [] |
| 10 | for (let i = 0; i < input.length; i += CHUNK_SIZE) { |
| 11 | // @ts-ignore |
| 12 | arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE))) |
| 13 | } |
| 14 | return btoa(arr.join('')) |
| 15 | } |
| 16 | |
| 17 | export function decodeBase64(encoded: string): Uint8Array { |
| 18 | // @ts-ignore |
no outgoing calls
no test coverage detected
searching dependent graphs…