n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
50 lines (49 loc) • 2.06 kB
TypeScript
/**
* Thai (Thailand) language converter
*
* CLDR: th-TH | Thai as used in Thailand
*
* Key features:
* - No word separators (continuous Thai script)
* - Million-based grouping (ล้าน)
* - Special handling for 1 as "เอ็ด" in compounds
* - 20 is "ยี่สิบ" (not "สองสิบ")
* - Per-digit decimal reading
*/
export declare const cardinalMax: null;
export declare const ordinalMax: null;
export declare const currencyMax: null;
/**
* Converts a numeric value to Thai words.
* @param {number | string | bigint} value - The numeric value to convert
* @returns {string} The number in Thai words
*/
declare function toCardinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Thai ordinal words.
* @param {number | string | bigint} value - The numeric value to convert (positive integer)
* @returns {string} The number as ordinal words
* @throws {TypeError} If value is not a valid numeric type
* @throws {RangeError} If value is negative, zero, or has a decimal part
* @example
* toOrdinal(1) // 'ที่หนึ่ง'
* toOrdinal(2) // 'ที่สอง'
* toOrdinal(10) // 'ที่สิบ'
*/
declare function toOrdinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Thai currency words (Baht).
*
* Thai Baht uses satang as subunit (100 satang = 1 baht).
* When whole amounts, adds "ถ้วน" (exactly) suffix.
* @param {number | string | bigint} value - The currency amount to convert
* @returns {string} The amount in Thai currency words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCurrency(42) // 'สี่สิบสองบาทถ้วน'
* toCurrency(1.50) // 'หนึ่งบาทห้าสิบสตางค์'
* toCurrency(-5) // 'ลบห้าบาทถ้วน'
*/
declare function toCurrency(value: number | string | bigint): string;
export { toCardinal, toOrdinal, toCurrency };