n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
55 lines (54 loc) • 2.12 kB
TypeScript
/**
* Swedish (Sweden) language converter
*
* CLDR: sv-SE | Swedish as used in Sweden
*
* Key features:
* - Hyphenation for tens-ones (tjugo-ett)
* - "och" after hundreds before small numbers
* - Omit "ett" before hundra and tusen
* - Use "en" (not "ett") before million+ scales
* - Long scale naming with -ard forms
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
/**
* Converts a numeric value to Swedish words.
* @param {number | string | bigint} value - The numeric value to convert
* @returns {string} The number in Swedish words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCardinal(42) // 'fyrtio-två'
* toCardinal(101) // 'hundra och ett'
* toCardinal(1000000) // 'en miljon'
*/
declare function toCardinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Swedish 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) // 'första'
* toOrdinal(2) // 'andra'
* toOrdinal(21) // 'tjugo-ettde'
*/
declare function toOrdinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Swedish currency words (Swedish Krona).
*
* Uses krona/kronor and öre (100 öre = 1 krona).
* @param {number | string | bigint} value - The currency amount to convert
* @returns {string} The amount in Swedish currency words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCurrency(1) // 'en krona'
* toCurrency(42) // 'fyrtio-två kronor'
* toCurrency(1.50) // 'en krona och femtio öre'
*/
declare function toCurrency(value: number | string | bigint): string;
export { toCardinal, toOrdinal, toCurrency };