* Convert a numeric byte array [137,80,78,...] to a base64 data URI.
(arr: number[])
| 430 | * Convert a numeric byte array [137,80,78,...] to a base64 data URI. |
| 431 | */ |
| 432 | function byteArrayToDataUri(arr: number[]): string | null { |
| 433 | if (!Array.isArray(arr) || arr.length < 8) return null; |
| 434 | const bytes = new Uint8Array(arr); |
| 435 | const mime = detectMimeType([bytes[0], bytes[1]]); |
| 436 | return `data:${mime};base64,${Buffer.from(bytes).toString('base64')}`; |
| 437 | } |
| 438 | |
| 439 | interface RawImageVariable { |
| 440 | kind?: string; |
no test coverage detected