UNPKG

byte-encodings

Version:

Utilities for encoding and decoding common formats like hex, base64, and varint. Ported from Deno's @std/encoding.

42 lines (39 loc) 1.09 kB
import { U as Uint8Array_ } from './_types-UoFpvNJp.js'; /** * Converts data into a base64-encoded string. * * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4} * * @param data The data to encode. * @returns The base64-encoded string. * * @example Usage * ```ts * import { encodeBase64 } from "@std/encoding/base64"; * import { assertEquals } from "@std/assert"; * * assertEquals(encodeBase64("foobar"), "Zm9vYmFy"); * ``` */ declare function encodeBase64(data: ArrayBuffer | Uint8Array | string): string; /** * Decodes a base64-encoded string. * * @see {@link https://www.rfc-editor.org/rfc/rfc4648.html#section-4} * * @param b64 The base64-encoded string to decode. * @returns The decoded data. * * @example Usage * ```ts * import { decodeBase64 } from "@std/encoding/base64"; * import { assertEquals } from "@std/assert"; * * assertEquals( * decodeBase64("Zm9vYmFy"), * new TextEncoder().encode("foobar") * ); * ``` */ declare function decodeBase64(b64: string): Uint8Array_; export { Uint8Array_, decodeBase64, encodeBase64 };