MCPcopy
hub / github.com/microsoft/playwright / typedArrayToBase64

Function typedArrayToBase64

packages/isomorphic/utilityScriptSerializers.ts:105–114  ·  view source on GitHub ↗
(array: any)

Source from the content-addressed store, hash-verified

103};
104
105function typedArrayToBase64(array: any) {
106 /**
107 * Firefox does not support iterating over typed arrays, so we use `.toBase64`.
108 * Error: 'Accessing TypedArray data over Xrays is slow, and forbidden in order to encourage performant code. To copy TypedArrays across origin boundaries, consider using Components.utils.cloneInto().'
109 */
110 if ('toBase64' in array)
111 return array.toBase64();
112 const binary = Array.from(new Uint8Array(array.buffer, array.byteOffset, array.byteLength)).map(b => String.fromCharCode(b)).join('');
113 return btoa(binary);
114}
115
116function base64ToTypedArray(base64: string, TypedArrayConstructor: any) {
117 const binary = atob(base64);

Callers 1

innerSerializeFunction · 0.85

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…