MCPcopy Create free account
hub / github.com/TanStack/ai / base64ToArrayBuffer

Function base64ToArrayBuffer

packages/ai-grok/src/utils/audio.ts:204–218  ·  view source on GitHub ↗
(base64: string)

Source from the content-addressed store, hash-verified

202}
203
204function base64ToArrayBuffer(base64: string): ArrayBuffer {
205 let binary: string
206 try {
207 binary = atob(base64)
208 } catch (err) {
209 const msg = err instanceof Error ? err.message : String(err)
210 throw new Error(`Invalid base64 input to toAudioFile: ${msg}`)
211 }
212 const buffer = new ArrayBuffer(binary.length)
213 const bytes = new Uint8Array(buffer)
214 for (let i = 0; i < binary.length; i++) {
215 bytes[i] = binary.charCodeAt(i)
216 }
217 return buffer
218}

Callers 1

toAudioFileFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected