n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
54 lines (53 loc) • 2.13 kB
TypeScript
/**
* Norwegian Bokmål (Norway) language converter
*
* CLDR: nb-NO | Norwegian Bokmål as used in Norway
*
* Key features:
* - Hyphenated tens+ones: "tjue-en" (21)
* - "og" conjunction after hundreds
* - Comma separator after thousands before hundreds
* - Short scale: million, milliard, billion, etc.
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
/**
* Converts a numeric value to Norwegian Bokmål words.
* @param {number | string | bigint} value - The numeric value to convert
* @returns {string} The number in Norwegian words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCardinal(21) // 'tjue-en'
* toCardinal(101) // 'en hundre og en'
* toCardinal(1000000) // 'en million'
*/
declare function toCardinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Norwegian Bokmål 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ørste'
* toOrdinal(2) // 'andre'
* toOrdinal(21) // 'tjue-ende'
*/
declare function toOrdinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Norwegian currency words (Norwegian Krone).
*
* Uses krone/kroner and øre (100 øre = 1 krone).
* @param {number | string | bigint} value - The currency amount to convert
* @returns {string} The amount in Norwegian 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 krone'
* toCurrency(42) // 'førti-to kroner'
* toCurrency(1.50) // 'en krone og femti øre'
*/
declare function toCurrency(value: number | string | bigint): string;
export { toCardinal, toOrdinal, toCurrency };