UNPKG

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) 655 B
import{c as n,d as t,e as o}from"./chunk-FH24VJR6.js";import{a as i}from"./chunk-JF3YMNGM.js";var s=61,c=new TextEncoder().encode("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),f=new Uint8Array(128).fill(32);c.forEach((e,r)=>f[e]=r);function l(e){typeof e=="string"?e=new TextEncoder().encode(e):e instanceof ArrayBuffer?e=new Uint8Array(e).slice():e=e.slice();let[r,y]=i(e,n(e.length));return t(r,y,0,c,s),new TextDecoder().decode(r)}function A(e){let r=new TextEncoder().encode(e);if(r.length%8)throw new TypeError(`Invalid base32 string: length (${r.length}) must be a multiple of 8`);return new Uint8Array(r.buffer.transfer(o(r,0,0,f,s)))}export{l as a,A as b};