MCPcopy Create free account
hub / github.com/ptmt/react-native-macos / binaryToBase64

Function binaryToBase64

Libraries/Utilities/binaryToBase64.js:16–28  ·  view source on GitHub ↗
(data: ArrayBuffer | $ArrayBufferView)

Source from the content-addressed store, hash-verified

14const base64 = require('base64-js');
15
16function binaryToBase64(data: ArrayBuffer | $ArrayBufferView) {
17 if (data instanceof ArrayBuffer) {
18 data = new Uint8Array(data);
19 }
20 if (data instanceof Uint8Array) {
21 return base64.fromByteArray(data);
22 }
23 if (!ArrayBuffer.isView(data)) {
24 throw new Error('data must be ArrayBuffer or typed array');
25 }
26 const {buffer, byteOffset, byteLength} = data;
27 return base64.fromByteArray(new Uint8Array(buffer, byteOffset, byteLength));
28}
29
30module.exports = binaryToBase64;

Callers 2

convertRequestBodyFunction · 0.85
sendMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…