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) 463 B
var r=new TextEncoder;function i(n){var e;let t=typeof n;return t!=="object"?t:n===null?"null":((e=n==null?void 0:n.constructor)==null?void 0:e.name)??"object"}function o(n){if(typeof n=="string")return r.encode(n);if(n instanceof Uint8Array)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);throw new TypeError(`Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer: received a value of the type ${i(n)}`)}export{o as a};