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) 586 B
import{c as o,d as a,e as i}from"./chunk-VAQA7TNE.js";import{a as r}from"./chunk-JF3YMNGM.js";var c=new TextEncoder().encode("0123456789abcdef"),n=new Uint8Array(128).fill(16);c.forEach((e,t)=>n[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>n[e]=t+10);function A(e){typeof e=="string"?e=new TextEncoder().encode(e):e instanceof ArrayBuffer?e=new Uint8Array(e).slice():e=e.slice();let[t,f]=r(e,o(e.length));return a(t,f,0,c),new TextDecoder().decode(t)}function p(e){let t=new TextEncoder().encode(e);return new Uint8Array(t.buffer.transfer(i(t,0,0,n)))}export{A as a,p as b};