UNPKG

base64-u8array-arraybuffer

Version:

A simple, lightweight, and efficient JavaScript library to manage encoding/decoding between base64 data, Uint8Arrays, and ArrayBuffers

3 lines (2 loc) 755 B
/*! base64-u8array-arraybuffer v1.0.3 | MIT */ const r="undefined"!=typeof window,e=e=>{const t=(r=>{const e=r.replace(/-/g,"+").replace(/_/g,"/");return e+"=".repeat((4-e.length%4)%4)})(e),n=(o=t,r?atob(o):Buffer.from(o,"base64").toString("binary"));var o;return Uint8Array.from(n,(r=>r.charCodeAt(0)))},t=e=>{const t=e.reduce(((r,e)=>r+String.fromCharCode(e)),"");return n=t,r?btoa(n):Buffer.from(n).toString("base64");var n},n=t,o=r=>r.buffer,a=o,f=r=>new Uint8Array(r),c=r=>{const t=e(r);return a(t)},u=r=>{const e=f(r);return n(e)};export{u as arrayBufferToBase64,f as arrayBufferToUint8Array,c as base64ToArrayBuffer,e as base64ToUint8Array,o as typedArrayToArrayBuffer,t as typedArrayToBase64,a as uint8ArrayToArrayBuffer,n as uint8ArrayToBase64};