Skip to content
1 min read · 102 words

Function: toBytes()

ts
function toBytes(input: SpecialistImageInput): Promise<{
  bytes: Uint8Array;
  mimeType?: string;
}>;

Defined in: src/batteries/specialists/_shared/index.ts:101

Normalizes any SpecialistImageInput form to plain bytes plus an optional MIME type.

Parameters

ParameterTypeDescription
inputSpecialistImageInputThe image/document input in any accepted form.

Returns

Promise<{ bytes: Uint8Array; mimeType?: string; }>

The normalized bytes and MIME type (MIME undefined only for the bare-Uint8Array form).

Remarks

A bare Uint8Array passes through with mimeType: undefined (the caller declared no MIME). A SpecialistBytesInput passes its bytes/mimeType through unchanged. A SpecialistMediaLike is resolved by awaiting asBytes() and reading mimeType off it.