UNPKG

n2words

Version:

n2words converts a numerical number into a written one, supports 28 languages and has zero dependencies.

110 lines (109 loc) 3.53 kB
/** * Converts a value to cardinal (written) form. * @param {number|string|bigint} value Number to be convert. * @param {object} [options] Options for class. * @returns {string} Value in cardinal (written) format. */ export default function floatToCardinal(value: number | string | bigint, options?: object): string; export class N2WordsRO extends AbstractLanguage { constructor(options: any); /** @type {boolean} */ feminine: boolean; /** @type {object} */ ones: object; /** @type {object} */ onesFeminine: object; /** @type {object} */ tens: object; /** @type {object} */ tensMasculine: object; /** @type {object} */ twenties: object; /** @type {object} */ hundreds: object; /** * Romanian big units. * For each power group we keep: singular, plural, feminineUnits?, needsDe? * - 10^3: mie/mii (feminine units in chunk; "de" for chunk >= 20) * - 10^6: milion/milioane ("de" for chunk >= 20) * - 10^9: miliard/miliarde ("de" for chunk >= 20) */ thousands: { 1: { singular: string; plural: string; feminine: boolean; needsDe: boolean; }; 2: { singular: string; plural: string; feminine: boolean; needsDe: boolean; }; 3: { singular: string; plural: string; feminine: boolean; needsDe: boolean; }; 4: { singular: string; plural: string; feminine: boolean; needsDe: boolean; }; 5: { singular: string; plural: string; feminine: boolean; needsDe: boolean; }; 6: { singular: string; plural: string; feminine: boolean; needsDe: boolean; }; 7: { singular: string; plural: string; feminine: boolean; needsDe: boolean; }; 8: { singular: string; plural: string; feminine: boolean; needsDe: boolean; }; }; toCardinal(number: any): any; /** * Split numeric string into BigInt groups of size x from left to right. * @param {string} n - The numeric string to split * @param {number} x - The size of each group * @returns {bigint[]} Array of BigInt groups */ splitByX(n: string, x: number): bigint[]; getDigits(value: any): any; /** * Romanian pluralization & "de" rule for big units. * - 1 → singular with article ("o mie", "un milion", "un miliard", …) * - otherwise → spell chunk + (optional "de") + plural * "de" is inserted when chunk >= 20 (e.g., "douăzeci de mii/milioane/miliarde"). * @param {bigint} chunk - The chunk value * @param {object} form - The form object with singular, plural, feminine, needsDe properties * @returns {string} The pluralized form */ romanianPluralize(chunk: bigint, form: object): string; spellUnder100(n: any, feminineUnits?: boolean): any; spellUnder1000(n: any, feminineUnits?: boolean): any; /** * Convert number to cardinal form using masculine units * @param {bigint} number Number to convert * @returns {string} Value in written format */ toCardinalWithMasculine(number: bigint): string; } import AbstractLanguage from '../classes/abstract-language.js';