(bytes: Uint8Array)
| 768 | } |
| 769 | |
| 770 | function bytesToBase64(bytes: Uint8Array): string { |
| 771 | const alphabet = |
| 772 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' |
| 773 | let output = '' |
| 774 | |
| 775 | for (let index = 0; index < bytes.length; index += 3) { |
| 776 | const first = bytes[index] ?? 0 |
| 777 | const second = index + 1 < bytes.length ? bytes[index + 1] : undefined |
| 778 | const third = index + 2 < bytes.length ? bytes[index + 2] : undefined |
| 779 | const combined = (first << 16) | ((second ?? 0) << 8) | (third ?? 0) |
| 780 | |
| 781 | output += alphabet[(combined >> 18) & 63] |
| 782 | output += alphabet[(combined >> 12) & 63] |
| 783 | output += second === undefined ? '=' : alphabet[(combined >> 6) & 63] |
| 784 | output += third === undefined ? '=' : alphabet[combined & 63] |
| 785 | } |
| 786 | |
| 787 | return output |
| 788 | } |
| 789 | |
| 790 | function svgDataUrl(title: string, prompt: string, color: string): string { |
| 791 | const safeTitle = escapeXml(title) |
no outgoing calls
no test coverage detected