UNPKG

@technobuddha/library

Version:
57 lines (56 loc) 1.65 kB
import { type Numbering } from './numbering.ts'; /** * Options for formatting ordinal numbers. * * @group Math * @category Numbers */ export type OrdinalOptions = { /** * Output format for the number representation. * @defaultValue 'alphabetic' */ output?: 'suffix' | 'numeric' | 'alphabetic' | 'hybrid' | Numbering['output']; /** * Text to use for "and" in compound numbers (e.g., "one hundred and one"). * @defaultValue (empty string) */ and?: Numbering['and']; /** * Text to use for hyphens in compound numbers (e.g., "twenty-one"). * @defaultValue ' ' (space) */ hyphen?: Numbering['hyphen']; /** * Tolerance for floating-point comparison when converting decimals to fractions. * @defaultValue 0.01 */ tolerance?: Numbering['tolerance']; /** * Type of denominators to use when expressing fractions. * @defaultValue 'common' */ denominators?: Numbering['denominators']; /** * Precision for decimal/fraction conversion. * @defaultValue 9 */ precision?: Numbering['precision']; /** * Whether to output ordinal numbers (e.g., "first", "second") instead of cardinal numbers. * @defaultValue false */ ordinal?: Numbering['ordinal']; /** * Whether to shift the fractional part of the number. */ shift?: Numbering['shift']; }; /** * Convert a number into an ordinal number string (1st, 2nd, 3rd, etc). * @param input - The number to convert * * @group Math * @category Numbers */ export declare function ordinal(input: number, options?: OrdinalOptions): string;