UNPKG

read-vietnamese-number

Version:
93 lines (92 loc) 3.4 kB
import { Digit, InputNumber, NumberData, Period, ReadingConfig } from './type.js'; /** * Read the last two digits of a number. * * @param config the reading configuration * @param b the digit in the tens place * @param c the digit in the units place * @returns an array of words */ export declare function readLastTwoDigits(config: ReadingConfig, b: Digit, c: Digit): string[]; /** * Read three digits in a period of a number. * * @param config the reading configuration * @param a the digit in the hundreds place * @param b the digit in the tens place * @param c the digit in the units place * @param readZeroHundred whether to read "zero" in the hundreds place * @returns an array of words */ export declare function readThreeDigits(config: ReadingConfig, a: Digit, b: Digit, c: Digit, readZeroHundred: boolean): string[]; /** * Remove thousands separators from the number string. * * @param config the reading configuration * @param number the number string * @returns the number string without thousands separators */ export declare function removeThousandsSeparators(config: ReadingConfig, number: string): string; /** * Remove redundant zeros from the number string from both ends. * * @param config the reading configuration * @param number the number string * @returns the number string without redundant zeros from both ends */ export declare function trimRedundantZeros(config: ReadingConfig, number: string): string; /** * Add leading zeros to the number string so its length is a multiple of the period size. * * @param number the number string * @returns the number string with leading zeros added */ export declare function addLeadingZerosToFitPeriod(number: string): string; /** * Group the digits in the integral part into periods of three digits each. * * @param digits the digits in the integral part * @returns an array of periods */ export declare function zipIntegralPeriods(digits: Digit[]): Period[]; /** * Parse the number string into a number data. * * @param config the reading configuration * @param number the number string * @returns a parsed number data * @throws InvalidNumberError if the number string is invalid */ export declare function parseNumberData(config: ReadingConfig, number: string): NumberData; /** * Read the periods in the integral part of a number. * * @param config the reading configuration * @param periods the periods in the integral part * @returns an array of words */ export declare function readIntegralPart(config: ReadingConfig, periods: Period[]): string[]; /** * Read the digits in the fractional part of a number. * * @param config the reading configuration * @param digits the digits in the fractional part * @returns an array of words */ export declare function readFractionalPart(config: ReadingConfig, digits: Digit[]): string[]; /** * Read the parsed number data. * * @param config the reading configuration * @param numberData the parsed number data * @returns a string representation of the number */ export declare function readNumber(config: ReadingConfig, numberData: NumberData): string; /** * Validate, parse, and read the input number. * * @param number the input number * @param config the reading configuration * @returns a string representation of the number */ export declare function doReadNumber(number: InputNumber, config?: ReadingConfig): string;