(array: any)
| 103 | }; |
| 104 | |
| 105 | function 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 | |
| 116 | function base64ToTypedArray(base64: string, TypedArrayConstructor: any) { |
| 117 | const binary = atob(base64); |
no test coverage detected
searching dependent graphs…