n2words
Version:
Convert numbers to words in 70+ languages with zero dependencies. Supports BigInt, decimals, and browser/Node.js environments.
56 lines (55 loc) • 2.21 kB
TypeScript
/**
* Kenyan English language converter
*
* CLDR: en-KE | English as used in Kenya
*
* Exports:
* - toCardinal(value) - Cardinal numbers: 42 → "forty-two"
* - toOrdinal(value) - Ordinal numbers: 42 → "forty-second"
* - toCurrency(value, options?) - Currency: 42.50 → "forty-two shillings and fifty cents"
*
* Kenyan English conventions:
* - Follows British English style
* - "and" after hundreds: "one hundred and twenty-three"
* - "and" before final segment: "one million and one"
* - Hyphenated tens-ones: "twenty-one", "forty-two"
* - Western numbering system (short scale: billion = 10^9)
* - Currency: Kenyan Shilling (KES) - shilling/shillings, cent/cents
*/
export declare const cardinalMax: bigint;
export declare const ordinalMax: bigint;
export declare const currencyMax: bigint;
/**
* Converts a numeric value to Kenyan English words.
* @param {number | string | bigint} value - The numeric value to convert
* @returns {string} The number in English words
* @throws {TypeError} If value is not a valid numeric type
* @throws {Error} If value is not a valid number format
*/
declare function toCardinal(value: number | string | bigint): string;
/**
* Converts a numeric value to Kenyan English ordinal words.
* @param {number | string | bigint} value - The numeric value to convert
* @returns {string} The ordinal in English words
*/
declare function toOrdinal(value: number | string | bigint): string;
export type CurrencyOptions = {
/**
* - Use "and" between shillings and cents
*/
and?: boolean;
};
/**
* @typedef {object} CurrencyOptions
* @property {boolean} [and] - Use "and" between shillings and cents
*/
/** @type {Required<CurrencyOptions>} */
export declare const currencyDefaults: Required<CurrencyOptions>;
/**
* Converts a numeric value to Kenyan English currency words.
* @param {number | string | bigint} value - The numeric value to convert
* @param {CurrencyOptions} [options] - Optional configuration
* @returns {string} The currency in English words
*/
declare function toCurrency(value: number | string | bigint, options?: CurrencyOptions): string;
export { toCardinal, toOrdinal, toCurrency };