byte-encodings
Version:
Utilities for encoding and decoding common formats like hex, base64, and varint. Ported from Deno's @std/encoding.
41 lines (38 loc) • 953 B
text/typescript
import { U as Uint8Array_ } from './_types-UoFpvNJp.cjs';
/**
* Converts data into a hex-encoded string.
*
* @param src The data to encode.
*
* @returns The hex-encoded string.
*
* @example Usage
* ```ts
* import { encodeHex } from "@std/encoding/hex";
* import { assertEquals } from "@std/assert";
*
* assertEquals(encodeHex("abc"), "616263");
* ```
*/
declare function encodeHex(src: string | Uint8Array | ArrayBuffer): string;
/**
* Decodes the given hex-encoded string. If the input is malformed, an error is
* thrown.
*
* @param src The hex-encoded string to decode.
*
* @returns The decoded data.
*
* @example Usage
* ```ts
* import { decodeHex } from "@std/encoding/hex";
* import { assertEquals } from "@std/assert";
*
* assertEquals(
* decodeHex("616263"),
* new TextEncoder().encode("abc"),
* );
* ```
*/
declare function decodeHex(src: string): Uint8Array_;
export { Uint8Array_, decodeHex, encodeHex };