@technobuddha/library
Version:
A large library of useful functions
27 lines (26 loc) • 1.09 kB
TypeScript
import { type TextEncoding } from './@types/text-encoding.ts';
/**
* Decode a [Base64](https://developer.mozilla.org/en-US/docs/Glossary/Base64) encoded string and
* output in binary format.
* @param input - A string containing the Base64 encoded data to decode.
* @returns An `Uint8Array` containing the decoded data.
* @example
* ```typescript
* decodeBase64('SGVsbG8sIHdvcmxkIQ==');
* // Uint8Array([72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33])
* ```
*/
export declare function decodeBase64(input: string): Uint8Array;
/**
* Decode a [Base64](https://developer.mozilla.org/en-US/docs/Glossary/Base64) encoded string as a
* string with the specified text encoding.
* @param input - A string containing the Base64 encoded data to decode.
* @param encoding - The text encoding to use for the decoded string.
* @returns An `string` containing the decoded data.
* @example
* ```typescript
* decodeBase64('SGVsbG8sIHdvcmxkIQ==', 'utf-8');
* // "Hello, world!"
* ```
*/
export declare function decodeBase64(input: string, encoding: TextEncoding): string;