n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
91 lines (90 loc) • 3.33 kB
TypeScript
/**
* Dutch (Netherlands) language converter
*
* CLDR: nl-NL | Dutch as used in the Netherlands
*
* Dutch-specific rules:
* - Inverted tens-ones: eenentwintig (one-and-twenty)
* - "ën" connector when ones ends in 'e' (twee, drie)
* - Compound words without spaces
* - Hundred pairing for 1100-9999 (elfhonderd style)
* - "één" vs "een" (accentOne option)
* - Optional "en" separator (includeOptionalAnd option)
* - Long scale with -ard forms
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
export type CardinalOptions = {
/**
* - Use "één" instead of "een"
*/
accentOne?: boolean;
/**
* - Include "en" before small numbers
*/
includeOptionalAnd?: boolean;
/**
* - Disable hundred pairing (1104→duizend honderdvier)
*/
noHundredPairing?: boolean;
};
/**
* @typedef {object} CardinalOptions
* @property {boolean} [accentOne] - Use "één" instead of "een"
* @property {boolean} [includeOptionalAnd] - Include "en" before small numbers
* @property {boolean} [noHundredPairing] - Disable hundred pairing (1104→duizend honderdvier)
*/
/** @type {Required<CardinalOptions>} */
export declare const cardinalDefaults: Required<CardinalOptions>;
/**
* Converts a numeric value to Dutch words.
*
* This is the main public API. It accepts any valid numeric input
* (number, string, or bigint) and handles parsing internally.
* @param {number | string | bigint} value - The numeric value to convert
* @param {CardinalOptions} [options] - Optional configuration
* @returns {string} The number in Dutch words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
* @example
* toCardinal(21) // 'eenentwintig'
* toCardinal(1) // 'één'
* toCardinal(1, {accentOne: false}) // 'een'
* toCardinal(1104) // 'elfhonderd vier'
*/
declare function toCardinal(value: number | string | bigint, options?: CardinalOptions): string;
/**
* Converts a number to Dutch ordinal words.
* @param {number | string | bigint} value - The number to convert
* @returns {string} Dutch ordinal words
* @example
* toOrdinal(1) // 'eerste'
* toOrdinal(21) // 'eenentwintigste'
* toOrdinal(100) // 'honderdste'
*/
declare function toOrdinal(value: number | string | bigint): string;
export type CurrencyOptions = {
/**
* - Include "en" between euros and cents
*/
and?: boolean;
};
/**
* @typedef {object} CurrencyOptions
* @property {boolean} [and] - Include "en" between euros and cents
*/
/** @type {Required<CurrencyOptions>} */
export declare const currencyDefaults: Required<CurrencyOptions>;
/**
* Converts a number to Dutch currency words (Euro).
* @param {number | string | bigint} value - The amount to convert
* @param {CurrencyOptions} [options] Optional configuration
* @returns {string} Dutch currency words
* @example
* toCurrency(42.50) // 'tweeënveertig euro en vijftig cent'
* toCurrency(1) // 'één euro'
* toCurrency(0.01) // 'één cent'
*/
declare function toCurrency(value: number | string | bigint, options?: CurrencyOptions): string;
export { toCardinal, toOrdinal, toCurrency };