n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
48 lines (47 loc) • 1.91 kB
TypeScript
/**
* Malay (Malaysia) language converter
*
* CLDR: ms-MY | Malay (Bahasa Melayu) as used in Malaysia
*
* Key features:
* - "Se-" prefix for ALL singular scale units (seratus, seribu, sejuta, sebilion)
* - Regular patterns (puluh for tens, ratus for hundreds)
* - Teens with "belas" suffix
* - Note: "lapan" (8) differs from Indonesian "delapan"
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
/**
* Converts a numeric value to Malay words.
* @param {number | string | bigint} value - The numeric value to convert
* @returns {string} The number in Malay words
*/
declare function toCardinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Malay 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) // 'pertama'
* toOrdinal(2) // 'kedua'
* toOrdinal(10) // 'kesepuluh'
*/
declare function toOrdinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Malay currency words (Ringgit).
*
* Malaysian Ringgit uses sen as subunit (100 sen = 1 ringgit).
* @param {number | string | bigint} value - The currency amount to convert
* @returns {string} The amount in Malay 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) // 'empat puluh dua ringgit'
* toCurrency(1.50) // 'satu ringgit lima puluh sen'
* toCurrency(-5) // 'minus lima ringgit'
*/
declare function toCurrency(value: number | string | bigint): string;
export { toCardinal, toOrdinal, toCurrency };