decodeBase64

import { decodeBase64 } from "jsr:@ende/encoding/unstable-base64";

function ยท experimental

function decodeBase64(input: string | Uint8Array_, options: Base64Options = [UNSUPPORTED]): Uint8Array_

decodeBase64 takes an input source and decodes it into a Uint8Array<ArrayBuffer> using the specified format.

input: string | Uint8Array_

The input source to decode.

options: Base64Options = [UNSUPPORTED]

The options to use for decoding.

Returns

The decoded Uint8Array<ArrayBuffer>.

Example: Basic Usage

import { assertEquals } from "@ende/assert";
import { decodeBase64 } from "@ende/encoding/unstable-base64";

assertEquals(
  decodeBase64("SGVsbG8gV29ybGQ=", { alphabet: "base64" }),
  new TextEncoder().encode("Hello World"),
);

assertEquals(
  decodeBase64("SGVsbG8gV29ybGQ", { alphabet: "base64url" }),
  new TextEncoder().encode("Hello World"),
);

Source