MCPcopy Create free account
hub / github.com/microsoft/AI-Engineering-Coach / byteArrayToDataUri

Function byteArrayToDataUri

src/core/parser-vscode-files.ts:432–437  ·  view source on GitHub ↗

* Convert a numeric byte array [137,80,78,...] to a base64 data URI.

(arr: number[])

Source from the content-addressed store, hash-verified

430 * Convert a numeric byte array [137,80,78,...] to a base64 data URI.
431 */
432function 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
439interface RawImageVariable {
440 kind?: string;

Callers 1

Calls 2

detectMimeTypeFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected