INNER CODE UNIT · TypeScript
decode
vercel/server-components-notes-demo · libs/session.ts:14
function decode(value) {
return new TextDecoder().decode(value)
}
function base64ToArrayBuffer(base64) {
const binary = atob(base64)
const len = binary.length
const bytes = new Uint8Array(len)
for (let i = 0; i < len; i++) {
bytes[i] = binary.charCodeAt(i)
}
return bytes.buffer
}
function arrayBufferToBase64(buffer) {
const bytes = new Uint8Array(buffer)
// @ts-ignore
const binary = String.fromCharCode(...bytes)