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.84 kB
TypeScript
/**
* Persian (Iran) language converter
*
* CLDR: fa-IR | Persian as used in Iran
*
* Key features:
* - "و" (and) conjunction for compound numbers
* - Omit "یک" (one) before thousand
* - Pre-composed hundreds (دویست, سيصد, etc.)
*/
export declare const cardinalMax: null;
export declare const ordinalMax: null;
export declare const currencyMax: null;
/**
* Converts a numeric value to Persian words.
* @param {number | string | bigint} value - The numeric value to convert
* @returns {string} The number in Persian words
*/
declare function toCardinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Persian 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 Persian currency words (Rial).
*
* Iranian Rial has no subunit in modern usage.
* (Historically dinar was 1/100 rial, but not used today)
* @param {number | string | bigint} value - The currency amount to convert
* @returns {string} The amount in Persian 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(1000) // 'هزار ریال'
* toCurrency(-5) // 'منفى پنج ریال'
*/
declare function toCurrency(value: number | string | bigint): string;
export { toCardinal, toOrdinal, toCurrency };