byte-encodings
Version:
Utilities for encoding and decoding common formats like hex, base64, and varint. Ported from Deno's @std/encoding.
2 lines (1 loc) • 577 B
JavaScript
import{c as t,d as o,e as i}from"./chunk-KSXH2JGP.js";import{a as n}from"./chunk-JF3YMNGM.js";var c=61,s=new TextEncoder().encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),f=new Uint8Array(128).fill(64);s.forEach((e,r)=>f[e]=r);function a(e){typeof e=="string"?e=new TextEncoder().encode(e):e instanceof ArrayBuffer?e=new Uint8Array(e).slice():e=e.slice();let[r,y]=n(e,t(e.length));return o(r,y,0,s,c),new TextDecoder().decode(r)}function u(e){let r=new TextEncoder().encode(e);return new Uint8Array(r.buffer.transfer(i(r,0,0,f,c)))}export{a,u as b};