n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
84 lines (83 loc) • 3.38 kB
TypeScript
/**
* Serbian (Serbia, Latin script) language converter
*
* CLDR: sr-Latn-RS | Serbian as used in Serbia (Latin script)
*
* Key features:
* - Three-form pluralization (one/few/many)
* - Gender by scale word: the -arda forms (hiljada, milijarda, bilijarda, ...)
* are feminine; the -ion forms (milion, bilion, ...) are masculine
* - Irregular hundreds (dvesta, trista, etc.)
* - Long scale naming with -ard forms
* - Latin script
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
export type CardinalOptions = {
/**
* - Grammatical gender
*/
gender?: ('masculine' | 'feminine');
};
/**
* @typedef {object} CardinalOptions
* @property {('masculine'|'feminine')} [gender] - Grammatical gender
*/
/** @type {Required<CardinalOptions>} */
export declare const cardinalDefaults: Required<CardinalOptions>;
/** @type {{ gender: ReadonlyArray<Required<CardinalOptions>['gender']> }} */
export declare const cardinalValues: {
gender: ReadonlyArray<Required<CardinalOptions>['gender']>;
};
/**
* Converts a numeric value to Serbian (Latin) words.
* @param {number | string | bigint} value - The numeric value to convert
* @param {CardinalOptions} [options] - Optional configuration
* @returns {string} The number in Serbian Latin words
*/
declare function toCardinal(value: number | string | bigint, options?: CardinalOptions): string;
/**
* Converts a numeric value to Serbian ordinal words (masculine nominative).
* @param {number | string | bigint} value - The numeric value to convert (must be a positive integer)
* @returns {string} The number as ordinal words (e.g., "prvi", "četrdeset drugi")
* @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) // 'prvi'
* toOrdinal(2) // 'drugi'
* toOrdinal(3) // 'treći'
* toOrdinal(21) // 'dvadeset prvi'
* toOrdinal(42) // 'četrdeset drugi'
* toOrdinal(100) // 'stoti'
* toOrdinal(1000) // 'hiljaditi'
*/
declare function toOrdinal(value: number | string | bigint): string;
export type CurrencyOptions = {
/**
* - Use "i" between dinars and para
*/
and?: boolean;
};
/**
* @typedef {object} CurrencyOptions
* @property {boolean} [and] - Use "i" between dinars and para
*/
/** @type {Required<CurrencyOptions>} */
export declare const currencyDefaults: Required<CurrencyOptions>;
/**
* Converts a numeric value to Serbian currency words (Serbian Dinar).
* @param {number | string | bigint} value - The currency amount to convert
* @param {CurrencyOptions} [options] - Optional configuration
* @returns {string} The amount in Serbian 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.50) // 'četrdeset dva dinara i pedeset para'
* toCurrency(1) // 'jedan dinar'
* toCurrency(0.99) // 'devedeset devet para'
* toCurrency(0.01) // 'jedna para'
* toCurrency(42.50, { and: false }) // 'četrdeset dva dinara pedeset para'
*/
declare function toCurrency(value: number | string | bigint, options?: CurrencyOptions): string;
export { toCardinal, toOrdinal, toCurrency };