MCPcopy
hub / github.com/panva/jose / encodeBase64

Function encodeBase64

src/lib/base64.ts:1–15  ·  view source on GitHub ↗
(input: Uint8Array)

Source from the content-addressed store, hash-verified

1export function encodeBase64(input: Uint8Array): string {
2 // @ts-ignore
3 if (Uint8Array.prototype.toBase64) {
4 // @ts-ignore
5 return input.toBase64()
6 }
7
8 const CHUNK_SIZE = 0x8000
9 const arr = []
10 for (let i = 0; i < input.length; i += CHUNK_SIZE) {
11 // @ts-ignore
12 arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)))
13 }
14 return btoa(arr.join(''))
15}
16
17export function decodeBase64(encoded: string): Uint8Array {
18 // @ts-ignore

Callers 3

genericExportFunction · 0.85
fromX509Function · 0.85
encodeFunction · 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…