Documentation / @agentick/shared / base64SourceToBuffer
Function: base64SourceToBuffer() ​
base64SourceToBuffer(
source):Uint8Array
Defined in: blocks.ts:633
Convert a Base64Source back to a Uint8Array.
Browser-compatible: returns Uint8Array which works in both Node.js and browser. In Node.js, you can convert to Buffer if needed: Buffer.from(uint8Array)
Parameters ​
source ​
Returns ​
Uint8Array
Example ​
typescript
if (imageBlock.source.type === 'base64') {
const uint8Array = base64SourceToBuffer(imageBlock.source);
// In Node.js, convert to Buffer if needed:
// const buffer = Buffer.from(uint8Array);
// In browser, use directly:
// const blob = new Blob([uint8Array], { type: 'image/png' });
}