UNPKG

@altostra/core

Version:

Core library for shared types and logic

45 lines (44 loc) 1.32 kB
/** * An alphabet is an ordered set of characters */ export interface Alphabet extends Iterable<string> { /** * Gets the count of characters in the alphabet */ readonly length: number; /** * Gets the character in the specified index * @param index The 0-based index of the character to retrieve */ getAt(index: number): string; /** * Gets the 0-based ordinal of the character in the alphabet * @param char The character to get ordinal of */ indexOf(char: string): number; /** * Checks if the character is contained alphabet * @param char The character to check */ has(char: string): boolean; } /** * All characters that serve as representation of a digit (E.G. in a case-insensitive * base, `['a', 'A']` represents the same digit) */ export declare type DigitVariants = string[]; /** * Represent an Nth base of a positional numeral system */ export interface NthBase { /** Gets the base radix value (N) */ readonly radix: number; /** * Gets an an ordered array of the digits in the base (first equals 0, second 1, etc.) */ readonly digits: readonly DigitVariants[]; /** * Gets a record that maps from digits to their value */ readonly values: Readonly<Record<string, number>>; }