MCPcopy Create free account
hub / github.com/tensorflow/tfjs / arrayBufferToBase64String

Function arrayBufferToBase64String

tfjs-core/src/io/io_utils.ts:424–434  ·  view source on GitHub ↗
(buffer: ArrayBuffer)

Source from the content-addressed store, hash-verified

422 * @returns A string that base64-encodes `buffer`.
423 */
424export function arrayBufferToBase64String(buffer: ArrayBuffer): string {
425 if (useNodeBuffer) {
426 return Buffer.from(buffer).toString('base64');
427 }
428 const buf = new Uint8Array(buffer);
429 let s = '';
430 for (let i = 0, l = buf.length; i < l; i++) {
431 s += String.fromCharCode(buf[i]);
432 }
433 return btoa(s);
434}
435
436/**
437 * Decode a base64 string as an ArrayBuffer.

Callers 3

findOverflowingByteSizeFunction · 0.90
io_utils_test.tsFile · 0.90
saveMethod · 0.90

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…