(buffer: ArrayBuffer)
| 17 | } |
| 18 | |
| 19 | export function arrayBufferToBase64(buffer: ArrayBuffer): string { |
| 20 | let bin = '' |
| 21 | const uint8 = new Uint8Array(buffer) |
| 22 | uint8.forEach((code: number) => { |
| 23 | bin += String.fromCharCode(code) |
| 24 | }) |
| 25 | return btoa(bin) |
| 26 | } |
| 27 | |
| 28 | export function b64ToUrlEncoded(str: string): string { |
| 29 | return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+/g, '') |