UNPKG

@waiting/base64

Version:

Base64 encoding/decoding in pure JS on both modern Browsers and Node.js. Also supports URL-safe base64

37 lines (36 loc) 1.61 kB
import { TextDecoderFn, TextEncoderFn } from './model'; /** Encode to base64, source from string | number | bigint */ export declare function b64encode(input: string | number | bigint, textEncoder?: TextEncoderFn): string; /** Decode base64 to string */ export declare function b64decode(base64: string, outputEncoding?: string, textDecoder?: TextDecoderFn): string; /** Encode to base64, source from ArrayBuffer or Uint8Array */ export declare function b64fromBuffer(buffer: ArrayBuffer | Uint8Array): string; /** * Calculate buffer.byteLength from base64 * * base64 is 4/3 + up to two characters of the original data */ export declare function b64byteLength(base64: string): number; /** * Encode to URL-safe base64, source from string | number | bigint. * Replace "+" to "-" and "/" to "_", and Remove "=". * * Note: using b64toURLSafe() for converting base64 string to URL-safe base64 string * * @see https://en.wikipedia.org/wiki/Base64#URL_applications */ export declare function b64urlEncode(input: string, textEncoder?: TextEncoderFn): string; /** * Encode to URL-safe base64, source from ArrayBuffer or Uint8Array * * @see https://en.wikipedia.org/wiki/Base64#URL_applications */ export declare function b64urlFromBuffer(buffer: ArrayBuffer | Uint8Array): string; /** * Decode URL-safe base64 to original string. * * Note: using b64fromURLSafe() for converting URL-safe base64 string to base64 string * * @see https://en.wikipedia.org/wiki/Base64#URL_applications */ export declare function b64urlDecode(input: string, outputEncoding?: string, textDecoder?: TextDecoderFn): string;