UNPKG

@waiting/base64

Version:

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

39 lines (38 loc) 2.04 kB
import { TextDecoderFn, TextEncoderFn } from './model'; export declare function parseEncodeInputString(input: string | number | bigint): string; export declare function parseDecodeInputBase64(base64: string): string; export declare function parseTextEncoder(textEncoder?: TextEncoderFn): TextEncoderFn; export declare function parseTextDecoder(textDecoder?: TextDecoderFn): TextDecoderFn; /** Whether string contains valid base64 characters */ export declare function validB64Chars(input: string): boolean; /** Whether string contains valid URL-safe base64 characters */ export declare function validB64URLChars(input: string): boolean; /** Validate input is valid base64 string or throw error */ export declare function validateB64(input: string): void; /** Validate input is valid URL-safe base64 string or throw error */ export declare function validateB64URL(input: string): void; /** Return true for valid base64 input, error message for invalid */ export declare function testB64(input: string): true | string; /** Return true for valid URL-safe base64 input, error message for invalid */ export declare function testB64URL(input: string): true | string; /** Whether running in Node.js */ export declare function isRunningInNodejs(): boolean; /** Whether input is instance of ArrayBuffer */ export declare function isArrayBuffer(buffer: any): buffer is ArrayBuffer; /** Whether input is instance of Uint8Array */ export declare function isUint8Array(buffer: any): buffer is Uint8Array; /** * Convert base64 string to URL-safe base64 string. * Replace "+" to "-" and "/" to "_", and Remove "=" * * @see https://en.wikipedia.org/wiki/Base64#URL_applications */ export declare function b64toURLSafe(base64: string): string; /** * Convert URL-safe base64 string to base64 string. * Replace "-" to "+" and "_" to "/", and pad with "=" * * @see https://en.wikipedia.org/wiki/Base64#URL_applications */ export declare function b64fromURLSafe(base64: string): string; export declare function b64PadSuffix(input: string): string;