do to formatters

This commit is contained in:
2026-01-24 01:07:43 +01:00
parent ae59df61eb
commit 891b3cf0ee
140 changed files with 656 additions and 1159 deletions

View File

@@ -0,0 +1,38 @@
/**
* AvatarDisplay
*
* Deterministic mapping of avatar-related data to display formats.
*/
export class AvatarFormatter {
/**
* Converts binary buffer to base64 string for display.
*/
static bufferToBase64(buffer: ArrayBuffer): string {
const bytes = new Uint8Array(buffer);
let binary = '';
for (let i = 0; i < bytes.byteLength; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary);
}
/**
* Determines if avatar data is valid for display.
* Accepts base64-encoded string buffer.
*/
static hasValidData(buffer: string, contentType: string): boolean {
return buffer.length > 0 && contentType.length > 0;
}
/**
* Formats content type for display (e.g., "image/png" → "PNG").
*/
static formatContentType(contentType: string): string {
const parts = contentType.split('/');
if (parts.length === 2) {
return parts[1].toUpperCase();
}
return contentType;
}
}